Beispiel #1
0
def test_load_data(tBeg, tEnd, SrcId):
   """tests whether data exists for the given time range to avoid IndexError issue."""
   try:
      src = das2.get_source(SrcId)
      dQuery = {'time':(tBeg, tEnd), 'hfr_i':True}
      dsReal = src.get(dQuery)[0]
	
   except (IndexError):
      return False
	
   else:
      return True
Beispiel #2
0
def getIQ(sSrcId, sBeg, sEnd):
   "Returns the tuple (dataset I, dataset Q)"""

   src = das2.get_source(sSrcId)

   print("Getting Reals from %s to %s"%(sBeg, sEnd))
   dQuery = {'time':(sBeg, sEnd), 'hfr_i':True}
   dsReal = src.get(dQuery)[0]
   print(dsReal)

   print("Getting Imaginary from %s to %s"%(sBeg, sEnd))
   dQuery = {'time':(sBeg, sEnd), 'hfr_q':True}
   dsImg = src.get(dQuery)[0]
   #print(dsImg)

   return (dsReal, dsImg, src)
Beispiel #3
0
# No she-bang here because we want the test target to pick the python version

import sys
import das2


#src = das2.get_source('site:/uiowa/juno/wav/survey/das2')
src = das2.get_source('site:/uiowa/cassini/rpws/survey_keyparam/das2')
lDs = src.httpGet({'start_time':'2016-10-02T11:00', 'end_time':'2016-10-02T12:00'})

for i in range(len(lDs)):
	print("Dataset 1:")
	print(lDs[i].info)
	
lDs = src.httpGet({'start_time':'2016-10-02T11:00', 'end_time':'2016-10-02T12:00'})

sys.exit(117)

src = das2.get_source('site:/uiowa/cassini/rpws/survey_keyparam/das2')

lDs = src.get(time=('2010-001','2010-002'), magnetic_specdens=1)


## For data items we want to be able to change units and to enable or
## disable various entries
#
lDs = src.get(time=('2014-08-31', '2014-09-01', 43.2), amp={'units':'DN'})



#
Beispiel #4
0
import numpy
import das2
import matplotlib.pyplot as pyplot
import matplotlib.colors as colors
import matplotlib.ticker as ticker

# Use the federated das2 catalog to find and download data given a source ID
sSourceId = "tag:das2.org,2012:site:/uiowa/cassini/rpws/survey/das2"
src = das2.get_source(sSourceId)
lDatasets = src.get()

# Combining multiple table datasets into a single homogeneous scatter dataset
# (most datasets are homogeneous and will not require this step)
lX = []
lY = []
lZ = []
for dataset in lDatasets:
    # As of numpy version 1.15, the numpy histogram routines won't work
    # with datetime64, and timedelta64 data types.  To Working around a
    # this problem time data are cast to the int64 type giving time values
    # as integer nanoseconds since 1970.
    lX.append(dataset.coords['time']['center'][:,:].flatten().astype("int64"))

    lY.append(dataset.coords['frequency']['center'][:,:].flatten() )
    lZ.append(dataset.data['amplitude']['center'][:,:].flatten() )

aX = numpy.ma.concatenate(lX)
aY = numpy.ma.concatenate(lY)
aZ = numpy.ma.concatenate(lZ)

import das2
import das2.mpl

import matplotlib.pyplot as pyplot
import matplotlib.colors as colors
import matplotlib.ticker as ticker

# The Cassini RPWS Survey data source is one of the most complicated das2 data
# sources at U. Iowa.  Data consist of multiple frequency sets from multiple
# recivers all attempting to cover the maximum parameter space within a limited
# telemetry alotment and on-board computing power.  This example collapses
# all the provided datasets to a single scatter set for plotting

sId = "site:/uiowa/cassini/rpws/survey/das2"
print("Getting data source definition for %s" % sId)
src = das2.get_source(sId)

print("Reading default example Cassini RPWS E-Survey data...")
lDs = src.get()

# Combining multiple spectra into one overall array set
print("Combining arrays...")
lX = []
lY = []
lZ = []
for ds in lDs:
    # As of numpy version 1.15, the numpy histogram routines won't work
    # with datetime64, and timedelta64 data types.  To Working around a
    # this problem time data are cast to the int64 type
    lX.append(ds['time']['center'].array.flatten().astype("int64"))
Beispiel #6
0
def main():

    # get a datasource, use it to download data

    sId = "test:/uiowa/mars_express/marsis/ne-density-planetographic/das2"
    src = das2.get_source(sId)
    print(src.info())

    beg = '2014-01-01'
    end = '2016-01-01'
    r_alt_max = 2000
    theta_sza_max = 135

    #query = {'alt':(0, 2000), 'sza':(0, theta_sza_max), 'time':(beg, end)}
    query = {'alt': (0, 2000), 'time': (beg, end)}
    datasets = src.get(query, verbose=True)
    ds = datasets[0]
    print(ds)

    # access the physical dimensions and numpy arrays in the dataset

    alt_dim = ds['alt']  # The altitude dimension
    alt_ary = ds.array('alt')  # equavalent to: ds['alt']['center'].array

    sza_dim = ds['sza']  # The solar zenith angle dimension
    sza_ary = ds.array('sza') * (np.pi / 180.0)  # scale to radians

    Ne_dim = ds['dens']  # The plasma density dimension
    Ne_ary = ds.array('dens')

    # Plotting...

    fig = pyplot.figure(figsize=(6, 4))

    loc_in_fig = [0.03, 0.0, 0.9, 0.9]
    r_offset = 1000

    title = "MARSIS - Plasma Density by Solar Zenith Angle and Altitude"
    sub_title = "%s to %s, SZA max %d$^\\circ$, expanded altitude scale" % (
        beg, end, theta_sza_max)
    theta_label = das2.mpl.label(sza_dim.props['label'])
    rad_label = das2.mpl.label(alt_dim.props['label'])

    cart_ax, pol_ax = make_axes(fig, loc_in_fig, r_alt_max, r_offset, title,
                                sub_title, theta_label, rad_label)

    # HexBin doesn't seem to work in polar space, use the cartesian axes
    x_ary, y_ary = to_cartesian(sza_ary, alt_ary, r_offset)

    color_scale = colors.LogNorm(10, 20000)
    hb = cart_ax.hexbin(x_ary,
                        y_ary,
                        Ne_ary,
                        gridsize=120,
                        mincnt=1,
                        norm=color_scale,
                        bins=None,
                        cmap='jet')

    # Colorbar axis
    density_label = "$\mathregular{N_{e}\\ (cm^{-3})}$"

    color_ax = fig.add_axes([0.87, 0.225, 0.02, 0.425])
    color_ax.text(3.0,
                  0.5,
                  density_label,
                  ha='center',
                  va='center',
                  transform=color_ax.transAxes,
                  rotation=90)

    fig.colorbar(hb, cax=color_ax)

    pyplot.show()