Skip to content

Commit

Permalink
Merge pull request #200 from pysat/maven_mgs
Browse files Browse the repository at this point in the history
Maven mgs
  • Loading branch information
jklenzing authored Oct 5, 2023
2 parents 807d60d + 2b03daa commit 8945d9d
Show file tree
Hide file tree
Showing 12 changed files with 387 additions and 11 deletions.
7 changes: 6 additions & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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"
}
]
}
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions docs/supported_instruments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pysatNASA/instruments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__:
Expand Down
94 changes: 94 additions & 0 deletions pysatNASA/instruments/maven_insitu_kp.py
Original file line number Diff line number Diff line change
@@ -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)
93 changes: 93 additions & 0 deletions pysatNASA/instruments/maven_mag.py
Original file line number Diff line number Diff line change
@@ -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)
105 changes: 105 additions & 0 deletions pysatNASA/instruments/maven_sep.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 3 additions & 1 deletion pysatNASA/instruments/methods/cdaweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Loading

0 comments on commit 8945d9d

Please sign in to comment.