pyValEIA.io.load ================ .. py:module:: pyValEIA.io.load .. autoapi-nested-parse:: Load supported data files. .. !! processed by numpydoc !! Functions --------- .. autoapisummary:: pyValEIA.io.load.load_cdf_data pyValEIA.io.load.extract_cdf_time pyValEIA.io.load.load_swarm pyValEIA.io.load.load_madrigal pyValEIA.io.load.load_nimo pyValEIA.io.load.load_daily_stats pyValEIA.io.load.multiday_states_report Module Contents --------------- .. py:function:: load_cdf_data(file_path, variable_names) Load a CDF file. :Parameters: **file_path** : str file path **variable_names** : array-like variable names for file to be extracted :Returns: **var_dict** : dict CDF file data with desired variables extracted **cdf_data** : cdflib.cdfread.CDF Loaded CDF data from `cdflib` .. seealso:: :obj:`cdflib.CDF` .. .. !! processed by numpydoc !! .. py:function:: extract_cdf_time(cdf_data, time_var='Timestamp') Extract common coordinate data from a CDF file object. :Parameters: **cdf_data** : cdflib.cdfread.CDF CDF data object from loaded file **time_var** : str Time variable (default='Timestamp') :Returns: **epoch** : array-like UT as datetime objects :Raises: ValueError If an incorrect variable name is requested .. !! processed by numpydoc !! .. py:function:: load_swarm(start_date, end_date, sat_id, file_dir, instrument='EFI', dataset='LP', f_end='0602') Load Swarm data, downloading any missing files. :Parameters: **start_date** : dt.datetime Starting time **end_date** : dt.datetime Ending time **sat_id** : str Swarm satellite ID, one of 'A', 'B', or 'C' **file_dir** : str File directory where the instrument directory is located. Files will be located in a directory tree specified by `download_and_unzip_swarm` **instrument** : str Swarm instrument (default='EFI') **dataset** : str Desired dataset acronym from instrument, e.g. 'LP' is Langmuir Probe (default='LP') **f_end** : str For different data products there are different numbers at the end The most common for EFIxLP is '0602' where '0602' represents the file version. Other datasets may also have a string that represents the record type (default='0602') :Returns: **swarm_data** : pd.DataFrame DataFrame of Swarm data for the desired instrument and satellite :Raises: ValueError If an unknown dataset is requested (currently only supports 'LP') .. !! processed by numpydoc !! .. py:function:: load_madrigal(stime, fdir) Load Madrigal TEC data from given time. :Parameters: **stime: datetime object** Universal time for the desired madrigal output **fdir** : str kwarg directory where file is located :Returns: **mad_dict** : dict Dictionary of the madrigal data including: TEC, geographic latitude, geographic longitude, TEC error (dTEC), timestamp, and date in the datetime format :Raises: ValueError If no file was found for the desired date .. rubric:: Notes This takes in madrgial files of format gps%y%m%dg.002.netCDF4 5 minute cadence .. !! processed by numpydoc !! .. py:function:: load_nimo(stime, file_dir, name_format='NIMO_AQ_%Y%j', ne_var='dene', lon_var='lon', lat_var='lat', alt_var='alt', hr_var='hour', min_var='minute', tec_var='tec', hmf2_var='hmf2', nmf2_var='nmf2', time_cadence=15) Load daily NIMO model files. :Parameters: **stime** : dt.datetime Day of desired NIMO run **file_dir** : str File directory, wildcards will be resolved but should only result in one file per day for the specified `name_format` **name_format** : str Format of NIMO file name including date format before .nc (default='NIMO_AQ_%Y%j') **ne_var** : str Electron density variable name (default='dene') **lon_var** : str Geographic longitude variable name (default='lon') **lat_var** : str Geodetic latitude variable name (default='lat') **alt_var** : str Altitude variable name (default='alt') **hr_var** : str UT hour variable name (default='hour') **min_var** : str UT minute variable name, or '' if not present (default='minute') **tec_var** : str TEC variable name (default='tec') **hmf2_var** : str hmF2 variable name (default='hmf2') **nmf2_var** : str NmF2 variable name (default='nmf2') **time_cadence** : int Model UT output time cadence of data in minutes (default=15) :Returns: **nimo_dc** : dict Dictionary with variables dene, glon, glat, alt, hour, minute, date, tec, nmf2, and hmf2 :Raises: ValueError If no NIMO file could be found at the specified location and time KeyError If an unexpected variable is supplied .. !! processed by numpydoc !! .. py:function:: load_daily_stats(stime, model, obs, file_dir, **kwargs) Load the daily statistics file with model-data comparisons. :Parameters: **stime** : datetime day of desired file **model** : str Case-sensitive name of model requested (e.g., 'NIMO', 'PyIRI'). **obs** : str Name of data set requested (e.g., 'SWARM', 'MADRIGAL') **file_dir** : str File directory **kwargs** : dict Optional kwargs by data type. Includes 'mad_lon', which expects longitudes of either -90 deg E or 60 deg E for Madrigal data. :Returns: **stat_data** : pd.DataFrame Dataframe that includes all information from type file :Raises: ValueError If expected file does not exist .. !! processed by numpydoc !! .. py:function:: multiday_states_report(date_range, daily_dir, model_name, obs_name, obs_constraint, comp_type='eia') Create a state report for a range of dates with a skill check. :Parameters: **date_range** : pd.DateRange Date range of desired states files **daily_dir** : str Directory containing the daily files **model_name** : str Case-sensitive model name to load, expects the capitalization used in the daily stats file header. (e.g., 'Nimo', 'PyIRI') **obs_name** : str Observation name to load (e.g., 'SWARM', 'MADRIGAL') **obs_constraint** : str or int Additional constraint for observation type. For Madrigal, this is the longitude as a integer. For Swarm, this is the altitude string, which currently accepts 'swarm', 'hmf2', or '100'. **comp_type** : str Desired type to check against for orientation or EIA state, expecting one of 'eia', 'peak', 'flat', or 'trough' for EIA state comparison or one of 'north', 'south', or 'neither' for an orientation comparison (default='eia') :Returns: **model_frame** : pd.DataFrame Model longitude, local time, states, directions, and EIA types. If Swarm observations are requested, will also contain a satellite list. **obs_frame** : pd.DataFrame Data longitude, local time, states, directions, and EIA types. If Swarm observations are requested, will also contain a satellite list. :Raises: ValueError For incompatible input combinations .. seealso:: :obj:`load_daily_stats` For accepted models, observations, and Madrigal longitudes .. !! processed by numpydoc !!