Reading in Data

This page will describe how to obtain and read in the data. For reading/loading Level 2 files, PySPEDAS is currently required.

Download Data

pydivide.download_files(filenames=None, instruments=None, list_files=False, level='l2', insitu=True, iuvs=False, new_files=False, start_date='2014-01-01', end_date='2020-01-01', update_prefs=False, only_update_prefs=False, exclude_orbit_file=False, local_dir=None, unittest=False, crustal_download=True)[source]

Download data files from the MAVEN SDC web server. Compatible with KP files or instrument-specific data downloads. insitu, iuvs, or at least one instrument must be specified.

Parameters:
  • filenames – str/list of str Specific filename strings to search/download.
  • instruments – str/list of str - swe, swi, ngi, euv, lpw, iuv, rse, sta, sep, acc Instruments from which you want to download data.
  • list_files – bool (True/False) If true, lists the files instead of downloading them.
  • level – str Data level to download.
  • insitu – bool (True/False) If true, specifies only insitu files.
  • iuvs – bool (True/False) If true,
  • new_files – bool (True/False) Checks downloaded files and only downloads those that haven’t already been downloaded.
  • start_date – str String that is the start date for downloading data (YYYY-MM-DD)
  • end_date – str String that is the end date for downloading data (YYYY-MM-DD)
  • update_prefs – bool (True/False) If true, updates where you want to store data locally
  • only_update_prefs – bool (True/False) If true, only updates where to store dat alocally, doesn’t download files.
  • exclude_orbit_file – bool (True/False) If true, won’t download the latest orbit tables.
  • local_dir – str If indicated, specifies where to download files for a specific implementation of this function.
  • unittest – bool If True, will not actually download files. If False (default) files will be downloaded.
  • crustal_download – bool If True (default), when insitu files are downloaded, any crustal files will also be downloaded. If False, crustal files will not be downloaded when insitu files are downloaded.
Returns:

None

Examples

>>> # Download all available insitu data between 2015-01-01 and 2015-01-31, inclusive:
>>> pydivide.download_files(start_date='2015-01-01', end_date='2015-01-31', insitu=True)
>>> # List all available CDF insitu KP files on the server:
>>> pydivide.download_files(insitu=True, list_files=True)
>>> # Download all new IUVS files from 6 April 2015 not found in the local directory.
>>> pydivide.download_files(iuvs=True, new_files=True, end_date='2015-04-06')
>>> # List all available Level 2 data files for SWIA.
>>> pydivide.download_files(instruments='swi', list_files=True, level='l2')
>>> # List all available Level 2 data files for SWIA for the month of January 2015.
>>> pydivide.download_files(start_date='2015-01-01', end_date='2015-01-31', instruments='swi', list_files=True, level='l2')
>>> # Download all new Level 2 data files for NGIMS, STATIC, and EUV.
>>> pydivide.download_files(instruments=['ngi','sta','euv'], new_files=True)

Read KP Data

pydivide.read(filename=None, input_time=None, instruments=None, insitu_only=False, specified_files_only=False)[source]

Read in a given filename in situ file into a dictionary object Optional keywords maybe used to downselect instruments returned and the time windows.

Parameters:
  • filename – str/list of str Name of the in situ KP file(s) to read in.
  • input_time – list of str/int Set a time bounds/filter on the data, must be length 2 with the first value being the start time, and the second value being the end time.
  • instruments – Optional keyword listing the instruments to include in the returned dictionary/structure.
  • insitu_only – Optional keyword that allows you to specify that you only want to download insitu files.
  • specified_files_only – Optional keyword that allows you to specify you only want filenames given in ‘filename’ to be read in, not other files close in date/time as well.
Returns:

A dictionary (data structure) containing up to all of the columns included in a MAVEN in-situ Key parameter data file.

Examples

>>> # Retrieve insitu and IUVS data for LPW and MAG on 2015-12-26.
>>> insitu,iuvs = pydivide.read('2015-12-26', instruments=['lpw','mag'])
>>> # Retrieve only insitu data for all instruments on 2017-06-19.
>>> insitu = pydivide.read('2017-06-19', insitu_only=True)

Read Model Results

pydivide.read_model_results(file)[source]

Reads results of specified simulation into a dictionary object containing sub-directories for metadata, dimension information, and model tracers. This function can read any of the models currently on the MAVEN SDC website with the .nc extension, which can be found here: https://lasp.colorado.edu/maven/sdc/public/pages/models.html The desired model must be downloaded prior to running this procedure

Parameters:file – str Simulation result file name to be read
Returns:
Dictionary roughly structured as follows
_ meta ()
_ longsubsol _ ls _ etc
_ dim
_ lat/x _ lon/y _ alt/z
_ variable1
_ dim_order (x,y,z or z,y,x for example) _ data
_ variable2
_ dim_order _ data

… _ variableN

Examples

>>> # Read the University of Michigan group’s ionospheric model for mean solar activity (F10.7 = 130).
>>> model = pydivide.read_model_results('<dir_path>/MGITM_LS270_F130_150519.nc')