diff --git a/.zenodo.json b/.zenodo.json index 1b5b3db1..6d54b11f 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -21,7 +21,7 @@ "orcid": "0000-0002-8191-4765" }, { - "affilitation":"University of Colorado at Boulder", + "affiliation":"University of Colorado at Boulder", "name": "Navarro, Luis", "orcid": "0000-0002-6362-6575" }, @@ -32,6 +32,11 @@ { "name": "Spence, Carey", "orcid": "0000-0001-8340-5625" + }, + { + "affiliation": "NASA Postdoctoral Program, Goddard Space Flight Center", + "name": "Esman, Teresa", + "orcid": "0000-0003-0382-6281" } ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 694c7bc8..afdb541d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,12 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [0.X.X] - 2023-XX-XX * New Instruments + * MAVEN mag + * MAVEN SEP + * MAVEN in situ key parameters * REACH Dosimeter -* Bug Fix +* Bug Fixes + * Fix general clean routine to skip transformation matrices * New window needs to be integer for calculate_imf_steadiness * Fixed version import * Documentation diff --git a/docs/supported_instruments.rst b/docs/supported_instruments.rst index deee1932..d01cf43a 100644 --- a/docs/supported_instruments.rst +++ b/docs/supported_instruments.rst @@ -178,6 +178,30 @@ JPL GPS .. automodule:: pysatNASA.instruments.jpl_gps :members: +.. _maven_insitu_kp: + +MAVEN INSITU KP +--------------- + +.. automodule:: pysatNASA.instruments.maven_insitu_kp + :members: + +.. _maven_mag: + +MAVEN MAG +--------- + +.. automodule:: pysatNASA.instruments.maven_mag + :members: + +.. _maven_sep: + +MAVEN SEP +--------- + +.. automodules:: pysatNASA.instruments.maven_sep + :members: + .. _omni_hro: OMNI HRO diff --git a/pysatNASA/instruments/__init__.py b/pysatNASA/instruments/__init__.py index e914912a..dfeb8391 100644 --- a/pysatNASA/instruments/__init__.py +++ b/pysatNASA/instruments/__init__.py @@ -11,7 +11,8 @@ 'de2_lang', 'de2_nacs', 'de2_rpa', 'de2_vefi', 'de2_wats', 'dmsp_ssusi', 'formosat1_ivm', 'icon_euv', 'icon_fuv', 'icon_ivm', 'icon_mighti', - 'igs_gps', 'iss_fpmu', 'jpl_gps', 'omni_hro', 'reach_dosimeter', + 'igs_gps', 'iss_fpmu', 'jpl_gps', 'maven_insitu_kp', + 'maven_mag', 'maven_sep', 'omni_hro', 'reach_dosimeter', 'ses14_gold', 'timed_guvi', 'timed_saber', 'timed_see'] for inst in __all__: diff --git a/pysatNASA/instruments/maven_insitu_kp.py b/pysatNASA/instruments/maven_insitu_kp.py new file mode 100644 index 00000000..660a3ad3 --- /dev/null +++ b/pysatNASA/instruments/maven_insitu_kp.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +"""Module for the MAVEN insitu instruments. + +Supports the in situ Key Parameter (kp) data from multiple instruments +onboard the Mars Atmosphere and Volatile Evolution (MAVEN) satellite. + +Accesses local data in CDF format. +Downloads from CDAWeb. + +Properties +---------- +platform + 'maven' +name + 'insitu_kp' +tag + None supported +inst_id + None supported + + +Examples +-------- +:: + import pysat + + insitu = pysat.Instrument(platform='maven', name='insitu_kp') + insitu.download(dt.datetime(2020, 1, 1), dt.datetime(2020, 1, 31)) + insitu.load(2020, 1, use_header=True) + +""" + +import datetime as dt +import functools + +from pysat.instruments.methods import general as mm_gen +from pysatNASA.instruments.methods import cdaweb as cdw +from pysatNASA.instruments.methods import general as mm_nasa +from pysatNASA.instruments.methods import maven as mm_mvn + +# ---------------------------------------------------------------------------- +# Instrument attributes + +platform = 'maven' +name = 'insitu_kp' +tags = {'': 'in situ Key Parameter data'} +inst_ids = {'': ['']} + +pandas_format = False + +# ---------------------------------------------------------------------------- +# Instrument test attributes + +_test_dates = {'': {'': dt.datetime(2020, 1, 1)}} + +# ---------------------------------------------------------------------------- +# Instrument methods + +# Use standard init routine +init = functools.partial(mm_nasa.init, module=mm_mvn, name=name) + + +# Use default clean +clean = functools.partial(mm_nasa.clean, + skip_names=['Rotation_matrix_IAU_MARS_MAVEN_MSO', + 'Rotation_matrix_SPACECRAFT_MAVEN_MSO']) + + +# ---------------------------------------------------------------------------- +# Instrument functions +# +# Use the MAVEN and pysat methods + +# Set the list_files routine +fname = ''.join(('mvn_insitu_kp-4sec_{year:04d}{month:02d}{day:02d}_', + 'v{version:02d}_r{revision:02d}.cdf')) +supported_tags = {'': {'': fname}} +list_files = functools.partial(mm_gen.list_files, + supported_tags=supported_tags) +# Set the download routine +basic_tag = {'remote_dir': ''.join(('/pub/data/maven/insitu/kp-4sec/', + 'cdfs/{year:04d}/{month:02d}')), + 'fname': fname} +download_tags = {'': {'': basic_tag}} +download = functools.partial(cdw.download, supported_tags=download_tags) + +# Set the list_remote_files routine +list_remote_files = functools.partial(cdw.list_remote_files, + supported_tags=download_tags) + + +# Set the load routine +load = functools.partial(cdw.load, epoch_name='epoch', + pandas_format=pandas_format, use_cdflib=True) diff --git a/pysatNASA/instruments/maven_mag.py b/pysatNASA/instruments/maven_mag.py new file mode 100644 index 00000000..c1125bd7 --- /dev/null +++ b/pysatNASA/instruments/maven_mag.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +"""Module for the MAVEN mag instrument. + +Supports the Magnetometer (MAG) onboard the Mars Atmosphere +and Volatile Evolution (MAVEN) satellite. +Accesses local data in CDF format. +Downloads from CDAWeb. + +Properties +---------- +platform + 'maven' +name + 'mag' +tag + None supported +inst_id + None supported + +Warnings +-------- + +- Only supports level-2 sunstate 1 second data. + +Examples +-------- +:: + import pysat + + mag = pysat.Instrument(platform='maven', name='mag') + mag.download(dt.datetime(2020, 1, 1), dt.datetime(2020, 1, 31)) + mag.load(2020, 1, use_header = True) + +""" + +import datetime as dt +import functools + +from pysat.instruments.methods import general as mm_gen +from pysatNASA.instruments.methods import cdaweb as cdw +from pysatNASA.instruments.methods import general as mm_nasa +from pysatNASA.instruments.methods import maven as mm_mvn + +# ---------------------------------------------------------------------------- +# Instrument attributes + +platform = 'maven' +name = 'mag' +tags = {'': 'Level 2 magnetometer data'} +inst_ids = {'': ['']} + +pandas_format = False +# ---------------------------------------------------------------------------- +# Instrument test attributes + +_test_dates = {'': {'': dt.datetime(2020, 1, 1)}} + +# ---------------------------------------------------------------------------- +# Instrument methods + +# Use standard init routine +init = functools.partial(mm_nasa.init, module=mm_mvn, name=name) + + +# Use default clean +clean = mm_nasa.clean + + +# ---------------------------------------------------------------------------- +# Instrument functions +# +# Use the CDAWeb and pysat methods + +# Set the list_files routine +fname = ''.join(('mvn_mag_l2-sunstate-1sec_{year:04d}{month:02d}{day:02d}_', + 'v{version:02d}_r{revision:02d}.cdf')) +supported_tags = {'': {'': fname}} +list_files = functools.partial(mm_gen.list_files, + supported_tags=supported_tags) +# Set the download routine +basic_tag = {'remote_dir': ''.join(('/pub/data/maven/mag/l2/sunstate-1sec', + '/cdfs/{year:04d}/{month:02d}')), + 'fname': fname} +download_tags = {'': {'': basic_tag}} +download = functools.partial(cdw.download, supported_tags=download_tags) + +# Set the list_remote_files routine +list_remote_files = functools.partial(cdw.list_remote_files, + supported_tags=download_tags) + +# Set the load routine +load = functools.partial(cdw.load, epoch_name='epoch', + pandas_format=pandas_format, use_cdflib=True) diff --git a/pysatNASA/instruments/maven_sep.py b/pysatNASA/instruments/maven_sep.py new file mode 100644 index 00000000..b1fe80b2 --- /dev/null +++ b/pysatNASA/instruments/maven_sep.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +"""Module for the MAVEN sep instrument. + +Supports the Solar Energetic Particle (SEP) data from +onboard the Mars Atmosphere and Volatile Evolution (MAVEN) satellite. + +Accesses local data in CDF format. +Downloads from CDAWeb. + +Properties +---------- +platform + 'maven' +name + 'sep' +tag + None supported +inst_id + ['s1', 's2'] + +Examples +-------- +:: + import pysat + + insitu = pysat.Instrument(platform='maven', name='sep', inst_id='s1') + insitu.download(dt.datetime(2020, 1, 1), dt.datetime(2020, 1, 31)) + insitu.load(2020, 1, use_header=True) + +""" + +import datetime as dt +import functools + +from pysat.instruments.methods import general as mm_gen +from pysatNASA.instruments.methods import cdaweb as cdw +from pysatNASA.instruments.methods import general as mm_nasa +from pysatNASA.instruments.methods import maven as mm_mvn + +# ---------------------------------------------------------------------------- +# Instrument attributes + +platform = 'maven' +name = 'sep' +tags = {'': 'Level 2 Solar Energetic Particle data'} +inst_ids = {'s1': [''], 's2': ['']} + +pandas_format = False + +# ---------------------------------------------------------------------------- +# Instrument test attributes + +_test_dates = {id: {'': dt.datetime(2020, 1, 1)} for id in inst_ids.keys()} + +# ---------------------------------------------------------------------------- +# Instrument methods + +# Use standard init routine +init = functools.partial(mm_nasa.init, module=mm_mvn, name=name) + + +# Use default clean +clean = mm_nasa.clean + + +# ---------------------------------------------------------------------------- +# Instrument functions +# +# Use the MAVEN and pysat methods + +# Set the list_files routine +fname = ''.join(('mvn_sep_l2_s1-cal-svy-full_{year:04d}{month:02d}{day:02d}_', + 'v{version:02d}_r{revision:02d}.cdf')) + +fname2 = ''.join(('mvn_sep_l2_s2-cal-svy-full_{year:04d}{month:02d}{day:02d}_', + 'v{version:02d}_r{revision:02d}.cdf')) + +supported_tags = {'s1': {'': fname}, + 's2': {'': fname2}} + +list_files = functools.partial(mm_gen.list_files, + supported_tags=supported_tags) + +# Set the download routine +basic_tag = {'remote_dir': ''.join(('/pub/data/maven/sep/l2/s1-cal-svy-full', + '/{year:04d}/{month:02d}')), + 'fname': fname} + +basic_tag2 = {'remote_dir': ''.join(('/pub/data/maven/sep/l2/s2-cal-svy-full', + '/{year:04d}/{month:02d}')), + 'fname': fname2} + +download_tags = {'s1': {'': basic_tag}, + 's2': {'': basic_tag2}} + +# Set the download routine +download = functools.partial(cdw.download, supported_tags=download_tags) + +# Set the list_remote_files routine +list_remote_files = functools.partial(cdw.list_remote_files, + supported_tags=download_tags) + +# Set the load routine +load = functools.partial(cdw.load, epoch_name='epoch', + pandas_format=pandas_format, use_cdflib=True) diff --git a/pysatNASA/instruments/methods/cdaweb.py b/pysatNASA/instruments/methods/cdaweb.py index 235090eb..3e3340fb 100644 --- a/pysatNASA/instruments/methods/cdaweb.py +++ b/pysatNASA/instruments/methods/cdaweb.py @@ -386,9 +386,11 @@ def load_xarray(fnames, tag='', inst_id='', ldata.append(temp_data) # Combine individual files together, concat along epoch - if len(ldata) > 0: + if len(ldata) > 1: data = xr.combine_nested(ldata, epoch_name, combine_attrs='override') + else: + data = ldata[0] all_vars = io.xarray_all_vars(data) diff --git a/pysatNASA/instruments/methods/general.py b/pysatNASA/instruments/methods/general.py index 1d075c46..16326279 100644 --- a/pysatNASA/instruments/methods/general.py +++ b/pysatNASA/instruments/methods/general.py @@ -51,24 +51,36 @@ def init(self, module, name): return -def clean(self): +def clean(self, skip_names=None): """Clean data to the specified level. + Parameters + ---------- + skip_names : list of str + List of names to skip for cleaning. (default=None) + Note ---- Basic cleaning to replace fill values with NaN """ - # Get a list of coords for the data + # Get a list of coords for the data. These should be skipped for cleaning. if self.pandas_format: - coords = [self.data.index.name] + skip_key = [self.data.index.name] else: - coords = [key for key in self.data.coords.keys()] + skip_key = [key for key in self.data.coords.keys()] + + if skip_names: + # Add additional variable names to skip + for key in skip_names: + skip_key.append(key) for key in self.variables: + # Check for symmetric dims + # Indicates transformation matrix, xarray cannot broadcast # Skip over the coordinates when cleaning - if key not in coords: + if key not in skip_key: fill = self.meta[key, self.meta.labels.fill_val] # Replace fill with nan diff --git a/pysatNASA/instruments/methods/maven.py b/pysatNASA/instruments/methods/maven.py new file mode 100644 index 00000000..d6a5aa6f --- /dev/null +++ b/pysatNASA/instruments/methods/maven.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +"""Provides non-instrument specific routines for MAVEN data. + +Created on Thu Jul 13 11:21:01 2023 + +@author: tesman +""" + +ackn_str = ''.join(('Jakosky, B.M., Lin, R.P., Grebowsky, J.M. et al.', + ' The Mars Atmosphere and Volatile Evolution', + '(MAVEN) Mission. Space Sci Rev 195, 3–48 (2015).', + ' https://doi.org/10.1007/s11214-015-0139-x')) +refs = {'mission': ''.join(('Jakosky, B.M., Lin, R.P., Grebowsky, J.M. et', + ' al. The Mars Atmosphere and Volatile Evolution', + '(MAVEN) Mission. Space Sci Rev', + ' 195, 3–48 (2015).', + ' https://doi.org/10.1007/s11214-015-0139-x')), + 'insitu_kp': '', + 'mag': ''.join(('Connerney, J., and P. Lawton, MAVEN MAG', + ' PDS Archive SIS - This document ', + 'describes the format and content of the MAVEN', + ' Magnetometer (MAG) Planetary Data System ', + '(PDS) data archive. ', + 'It includes descriptions of the Standard', + 'Data Products and associated metadata, ', + 'and the volume archive format,', + 'content, and generation pipeline. ', + 'Connerney, J.E.P.; Espley, J.; Lawton, P.;', + ' Murphy, S.; Odom, J.; Oliversen, R.;', + 'and Sheppard, D., The MAVEN Magnetic Field', + ' Investigation, Space Sci Rev,', + 'Vol 195, Iss 1-4, pp.257-291, 2015. ', + 'doi:10.1007/s11214-015-0169-4')), + 'sep': ''.join(('Larson, D.E., Lillis, R.J., Lee, C.O. et al.', + 'The MAVEN Solar Energetic Particle Investigation.', + ' Space Sci Rev 195, 153–172 (2015).', + ' https://doi.org/10.1007/s11214-015-0218-z'))} diff --git a/pysatNASA/tests/test_instruments.py b/pysatNASA/tests/test_instruments.py index 8b8ffb13..dea3dacb 100644 --- a/pysatNASA/tests/test_instruments.py +++ b/pysatNASA/tests/test_instruments.py @@ -18,7 +18,6 @@ # Make sure to import your instrument library here import pysatNASA - try: import pysatCDF # noqa: F401 # If this successfully imports, tests need to be run with both pysatCDF diff --git a/test_requirements.txt b/test_requirements.txt index 6c5e6eff..b0971689 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -10,4 +10,4 @@ pytest pytest-cov pytest-ordering sphinx -sphinx_rtd_theme +sphinx_rtd_theme>=1.2.2