pysat / pysatIncubator

pysat development lab for instruments
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

STY: use meta.labels #6

Closed jklenzing closed 3 years ago

jklenzing commented 3 years ago

Addresses pysat/pysat#587

Updates instruments to use the new meta.labels functionality. Note that none of these instruments have download support, and I don't have files. Therefore, none of these have been tested.

Also, due to the extensive use of non-label meta information in the demeter methods, these have been left alone and a note was added to the docstring.

jklenzing commented 3 years ago

Updated the style so that the dictionary objects throughout the methods are referred to as meta_dict consistently. Updated my note under the methods that we should re-evaluate meta usage here, but the actual pysat.Meta() should be compatible. I don't have files, but I've tried to "trick" the code into working via:

import pysat
from pysatIncubator.instruments.methods import demeter
name = 'iap'
meta_dict = {'data names': ['glat', 'glon', 'altitude', 'LT', 'mlat',
                            'mlon', 'MLT', 'ilat', 'L', 'glat_conj',
                            'glon_conj', 'glat_conj_N_110km',
                            'glon_conj_N_110km', 'glat_conj_S_110km',
                            'glon_conj_S_110km', 'mag_comp_1', 'mag_comp_2',
                            'mag_comp_3', 'proton_gyrofreq', 'Xs', 'Ys',
                            'Zs'],
             'data units': {'glat': 'degrees',
                            'glon': 'degrees',
                            'altitude': 'km',
                            'LT': 'h',
                            'mlat': 'degrees',
                            'mlon': 'degrees',
                            'MLT': 'h',
                            'ilat': 'degrees',
                            'L': 'Earth_Radii',
                            'glat_conj': 'degrees',
                            'glon_conj': 'degrees',
                            'glat_conj_N_110km': 'degrees',
                            'glon_conj_N_110km': 'degrees',
                            'glat_conj_S_110km': 'degrees',
                            'glon_conj_S_110km': 'degrees',
                            'mag_comp_1': 'nT',
                            'mag_comp_2': 'nT',
                            'mag_comp_3': 'nT',
                            'proton_gyrofreq': 'Hz',
                            'Xs': 'N/A',
                            'Ys': 'N/A',
                            'Zs': 'N/A'}}
meta = demeter.set_metadata(name, meta_dict)
meta

yields

Meta(metadata=                         units                                          long_name notes desc               plot               axis   scale value_min value_max fill
glat                   degrees                                Geocentric Latitude                          glat               glat  linear       NaN       NaN  NaN
glon                   degrees                               Geocentric Longitude                          glon               glon  linear       NaN       NaN  NaN
altitude                    km                                           Altitude                      altitude           altitude  linear       NaN       NaN  NaN
LT                           h                                         Local Time                            LT                 LT  linear       NaN       NaN  NaN
mlat                   degrees                               Geomagnetic Latitude                          mlat               mlat  linear       NaN       NaN  NaN
mlon                   degrees                              Geomagnetic Longitude                          mlon               mlon  linear       NaN       NaN  NaN
MLT                          h                                Magnetic Local Time                           MLT                MLT  linear       NaN       NaN  NaN
ilat                   degrees                                 Invarient Latitude                          ilat               ilat  linear       NaN       NaN  NaN
L                  Earth_Radii                              Mc Ilwain Parameter L                             L                  L  linear       NaN       NaN  NaN
glat_conj              degrees  Geocentric latitude of the conjugate point at ...                     glat_conj          glat_conj  linear       NaN       NaN  NaN
glon_conj              degrees  Geocentric longitude of the conjugate point at...                     glon_conj          glon_conj  linear       NaN       NaN  NaN
glat_conj_N_110km      degrees  Geocentric latitude of North conjugate point a...             glat_conj_N_110km  glat_conj_N_110km  linear       NaN       NaN  NaN
glon_conj_N_110km      degrees  Geocentric longitude of North conjugate point ...             glon_conj_N_110km  glon_conj_N_110km  linear       NaN       NaN  NaN
glat_conj_S_110km      degrees  Geocentric latitude of South conjugate point a...             glat_conj_S_110km  glat_conj_S_110km  linear       NaN       NaN  NaN
glon_conj_S_110km      degrees  Geocentric longitude of South conjugate point ...             glon_conj_S_110km  glon_conj_S_110km  linear       NaN       NaN  NaN
mag_comp_1                  nT  Component of the magnetic field model at the s...                    mag_comp_1         mag_comp_1  linear       NaN       NaN  NaN
mag_comp_2                  nT  Component of the magnetic field model at the s...                    mag_comp_2         mag_comp_2  linear       NaN       NaN  NaN
mag_comp_3                  nT  Component of the magnetic field model at the s...                    mag_comp_3         mag_comp_3  linear       NaN       NaN  NaN
proton_gyrofreq             Hz            Proton gyrofrequency at satellite point               proton_gyrofreq    proton_gyrofreq  linear       NaN       NaN  NaN
Xs                         N/A     Solar position in geographic coordinate system                            Xs                 Xs  linear       NaN       NaN  NaN
Ys                         N/A     Solar position in geographic coordinate system                            Ys                 Ys  linear       NaN       NaN  NaN
Zs                         N/A     Solar position in geographic coordinate system                            Zs                 Zs  linear       NaN       NaN  NaN, labels=MetaLabels(units=units <class 'str'>, name=long_name <class 'str'>, notes=notes <class 'str'>, desc=desc <class 'str'>, plot=plot <class 'str'>, axis=axis <class 'str'>, scale=scale <class 'str'>, min_val=value_min <class 'float'>, max_val=value_max <class 'float'>, fill_val=fill <class 'float'>)export_nan=['value_min', 'value_max', 'fill']) -> 22 Variables