-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: new GNSS TEC instrument #11
Changes from 36 commits
42d487f
5cdeffe
e35d5ce
aeab2f7
1fb3fc4
895b0e4
d599f62
12afe51
0e0f347
3cfa630
d32b71c
e8a714a
5684bb0
d7f42f1
c3f3965
b331197
626c87d
7d43205
9782e4d
318ca68
ab600b0
6da4347
1c7fb88
ebd3525
06a8c27
a529e75
f5b451a
bdbaee6
6dd3e57
1380341
59c5983
6908d09
5df53b1
ecf0403
dcf32ef
d9f3247
e69fd43
e94aec6
3029d4a
15dd2b3
54ab698
d7e64a3
9f25389
f316ad9
fc50297
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
from pysatMadrigal.instruments import dmsp_ivm, jro_isr | ||
# Import Madrigal instruments | ||
from pysatMadrigal.instruments import dmsp_ivm, gnss_tec, jro_isr | ||
|
||
# Import Madrigal methods | ||
from pysatMadrigal.instruments import methods # noqa F401 | ||
|
||
__all__ = ['dmsp_ivm', 'jro_isr'] | ||
# Define variable name with all available instruments | ||
__all__ = ['dmsp_ivm', 'gnss_tec', 'jro_isr'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
# -*- coding: utf-8 -*-. | ||
"""Supports the MIT Haystack GNSS TEC data products | ||
|
||
The Global Navigation Satellite System (GNSS) is used in conjunction with a | ||
world-wide receiver network to produce total electron content (TEC) data | ||
products, including vertical and line-of-sight TEC. | ||
|
||
Downloads data from the MIT Haystack Madrigal Database. | ||
|
||
Properties | ||
---------- | ||
platform | ||
'gnss' | ||
name | ||
'tec' | ||
tag | ||
'vtec' | ||
|
||
Examples | ||
-------- | ||
:: | ||
|
||
import datetime | ||
import pysat | ||
import pysatMadrigal as pymad | ||
|
||
vtec = pysat.Instrument(inst_module=pymad.instruments.gnss_tec, tag='vtec') | ||
vtec.download(dt.datetime(2017, 11, 19), dt.datetime(2017, 11, 20), | ||
user='Firstname+Lastname', password='email@address.com') | ||
vtec.load(date=dt.datetime(2017, 11, 19)) | ||
|
||
|
||
Note | ||
---- | ||
Please provide name and email when downloading data with this routine. | ||
|
||
""" | ||
|
||
import datetime as dt | ||
import functools | ||
import numpy as np | ||
|
||
from pysat.instruments.methods import general as ps_gen | ||
|
||
from pysatMadrigal.instruments.methods import madrigal as mad_meth | ||
|
||
import logging | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
platform = 'gnss' | ||
name = 'tec' | ||
tags = {'vtec': 'vertical TEC'} | ||
inst_ids = {'': [tag for tag in tags.keys()]} | ||
_test_dates = {'': {'vtec': dt.datetime(2017, 11, 19)}} | ||
pandas_format = False | ||
|
||
# support list files routine | ||
# use the default pysat method | ||
dname = '{year:02d}{month:02d}{day:02d}' | ||
vname = '.{version:03d}' | ||
supported_tags = {ss: {'vtec': "gps{:s}g{:s}.hdf5".format(dname, vname)} | ||
for ss in inst_ids.keys()} | ||
list_files = functools.partial(ps_gen.list_files, | ||
aburrell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
supported_tags=supported_tags, | ||
two_digit_year_break=99) | ||
|
||
# madrigal tags | ||
madrigal_inst_code = 8000 | ||
madrigal_tag = {'': {'vtec': 3500}} # , 'los': 3505}} | ||
|
||
# support listing files currently available on remote server (Madrigal) | ||
list_remote_files = functools.partial(mad_meth.list_remote_files, | ||
supported_tags=supported_tags, | ||
inst_code=madrigal_inst_code) | ||
|
||
|
||
def init(self): | ||
"""Initializes the Instrument object with values specific to GNSS TEC | ||
|
||
Runs once upon instantiation. | ||
|
||
""" | ||
|
||
ackn_str = ''.join(["GPS TEC data products and access through the ", | ||
"Madrigal distributed data system are provided to ", | ||
"the community by the Massachusetts Institute of ", | ||
"Technology under support from U.S. National Science", | ||
" Foundation grant AGS-1242204. Data for the TEC ", | ||
"processing is provided by the following ", | ||
"organizations: UNAVCO, Scripps Orbit and Permanent", | ||
" Array Center, Institut Geographique National, ", | ||
"France, International GNSS Service, The Crustal ", | ||
"Dynamics Data Information System (CDDIS), National ", | ||
" Geodetic Survey, Instituto Brasileiro de Geografia", | ||
aburrell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"e Estatística, RAMSAC CORS of Instituto Geográfico", | ||
" Nacional del la República Agentina, Arecibo ", | ||
"Observatory, Low-Latitude Ionospheric Sensor ", | ||
"Network (LISN), Topcon Positioning Systems, Inc., ", | ||
"Canadian High Arctic Ionospheric Network, ", | ||
"Institute of Geology and Geophysics, Chinese ", | ||
"Academy of Sciences, China Meterorology ", | ||
"Administration, Centro di Ricerche Sismogiche, ", | ||
"Système d’Observation du Niveau des Eaux Littorales", | ||
" (SONEL), RENAG : REseau NAtional GPS permanent, ", | ||
"and GeoNet—the official source of geological ", | ||
"hazard information for New Zealand.\n", | ||
mad_meth.cedar_rules()]) | ||
|
||
logger.info(ackn_str) | ||
self.acknowledgements = ackn_str | ||
self.references = "Rideout and Coster (2006) doi:10.1007/s10291-006-0029-5" | ||
|
||
return | ||
|
||
|
||
def download(date_array, tag='', inst_id='', data_path=None, user=None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I downloaded a few days for testing but the files I got are labeled There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, regardless of the format you ask for and get, the remote files are listed as .hdf5. Not sure if I fixed the rename here or in the other PR. |
||
password=None, url='http://cedar.openmadrigal.org', | ||
file_format='netCDF4'): | ||
"""Downloads data from Madrigal. | ||
|
||
Parameters | ||
---------- | ||
date_array : array-like | ||
list of datetimes to download data for. The sequence of dates need not | ||
be contiguous. | ||
tag : string | ||
Tag identifier used for particular dataset. This input is provided by | ||
pysat. (default='') | ||
inst_id : string | ||
Satellite ID string identifier used for particular dataset. This input | ||
aburrell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
is provided by pysat. (default='') | ||
data_path : string | ||
Path to directory to download data to. (default=None) | ||
user : string | ||
User string input used for download. Provided by user and passed via | ||
pysat. If an account is required for dowloads this routine here must | ||
aburrell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
error if user not supplied. (default=None) | ||
aburrell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
password : string | ||
Password for data download. (default=None) | ||
url : string | ||
URL for Madrigal site (default='http://cedar.openmadrigal.org') | ||
file_format : string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I tried checking out 'hdf5' support. Using the branch over in pysat (without the keyword) I get,
With the keyword,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was using the wrong pysat branch. You had the correct link above. My bad. Trying again... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My test setup was good the first time. Clearly I got myself turned around a bit. The test for 'hdf5' was done with the 'delimiter_bug` branch. I confirmed that I get the pop issue or the ValueError. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I apparently changed this bug in the following PR. Will update it here, too. Problems of finding too many related problems... |
||
File format for Madrigal data. Load routines currently only accepts | ||
'hdf5' and 'netCDF4', but any of the Madrigal options may be used | ||
here. (default='netCDF4') | ||
|
||
Note | ||
---- | ||
The user's names should be provided in field user. Anthea Coster should | ||
be entered as Anthea+Coster | ||
|
||
The password field should be the user's email address. These parameters | ||
are passed to Madrigal when downloading. | ||
|
||
The affiliation field is set to pysat to enable tracking of pysat | ||
downloads. | ||
|
||
""" | ||
mad_meth.download(date_array, inst_code=str(madrigal_inst_code), | ||
kindat=str(madrigal_tag[inst_id][tag]), | ||
data_path=data_path, user=user, password=password, | ||
file_format=file_format, url=url) | ||
return | ||
|
||
|
||
def load(fnames, tag=None, inst_id=None, file_format='netCDF4'): | ||
""" Routine to load the GNSS TEC data | ||
|
||
Parameters | ||
----------- | ||
fnames : list | ||
List of filenames | ||
tag : string or NoneType | ||
tag name used to identify particular data set to be loaded. | ||
This input is nominally provided by pysat itself. (default=None) | ||
inst_id : string or NoneType | ||
Satellite ID used to identify particular data set to be loaded. | ||
aburrell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This input is nominally provided by pysat itself. (default=None) | ||
file_format : string | ||
File format for Madrigal data. Currently only accepts 'hdf5' and | ||
'netCDF4', but any of the Madrigal options may be used here. | ||
aburrell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(default='netCDF4') | ||
|
||
Returns | ||
-------- | ||
data : xarray.Dataset | ||
Object containing satellite data | ||
meta : pysat.Meta | ||
Object containing metadata such as column names and units | ||
|
||
""" | ||
# Define the xarray coordinate dimensions (apart from time) | ||
# Not needed for netCDF | ||
xcoords = {'vtec': {('time', 'gdlat', 'glon', 'kindat', 'kinst'): | ||
['gdalt', 'tec', 'dtec'], | ||
('time', ): ['year', 'month', 'day', 'hour', 'min', | ||
'sec', 'ut1_unix', 'ut2_unix', 'recno']}} | ||
|
||
# Load the specified data | ||
data, meta = mad_meth.load(fnames, tag, inst_id, | ||
xarray_coords=xcoords[tag], | ||
file_format=file_format) | ||
|
||
# Squeeze the kindat and kinst 'coordinates', but keep them as floats | ||
squeeze_dims = np.array(['kindat', 'kinst']) | ||
squeeze_mask = [sdim in data.coords for sdim in squeeze_dims] | ||
if np.any(squeeze_mask): | ||
data = data.squeeze(dim=squeeze_dims[squeeze_mask]) | ||
|
||
# Fix the units for tec and dtec | ||
if tag == 'vtec': | ||
meta['tec'] = {meta.units_label: 'TECU'} | ||
meta['dtec'] = {meta.units_label: 'TECU'} | ||
|
||
return data, meta | ||
|
||
|
||
def clean(self): | ||
"""Routine to return GNSS TEC data at a specific level | ||
|
||
Note | ||
---- | ||
Supports 'clean', 'dusty', 'dirty', or 'None'. | ||
Routine is called by pysat, and not by the end user directly. | ||
|
||
""" | ||
if self.tag == "vtec": | ||
logger.info("".join(["Data provided at a clean level, further ", | ||
"cleaning may be performed using the ", | ||
"measurement error 'dtec'"])) | ||
|
||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is hardcoded to .hdf5.