Skip to content

Commit

Permalink
Added species attribute to FD property in new header
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Jan 29, 2015
1 parent a105829 commit aac162e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
8 changes: 5 additions & 3 deletions reflexible/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def add_trajectory(self):

@property
def FD(self):
return FD(self.nc, self.nspec, self.available_dates, self.direction)
return FD(self.nc, self.nspec, self.species, self.available_dates,
self.direction)

@property
def C(self):
Expand All @@ -225,9 +226,10 @@ def __init__(self, path=None):
class FD(object):
"""Class that contains FD data indexed with (spec, date)."""

def __init__(self, nc, nspec, available_dates, direction):
def __init__(self, nc, nspec, species, available_dates, direction):
self.nc = nc
self.nspec = nspec
self.species = species
self.available_dates = available_dates
self.direction = direction
self._keys = [(s, k) for s, k in itertools.product(
Expand All @@ -251,7 +253,7 @@ def __getitem__(self, item):
fdc.rel_i = 0
else:
fdc.rel_i = 'k'
# fdc.species = ... # XXX where to find species info?
fdc.species = self.species
# fdc.wet # TODO
# fdc.dry # TODO
return fdc
Expand Down
71 changes: 71 additions & 0 deletions tiny_test2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import sys
import os.path

import reflexible as rf
import reflexible.conv2netcdf4 as conv

H = conv.Header("/tmp/test_data")
print "******* Original Header ***********"
print "keys:", H.keys()
print "available_dates:", H.available_dates
print "releasestart:", H.releasestart
print "releaseend:", H.releaseend
print "releasetimes", H.releasetimes
print ""

Hnc = rf.Header("/tmp/grid_time_20100601210000.nc")
print "******* netCDF4 Header ***********"
print "keys:", Hnc.keys()
print "available_dates:", Hnc.available_dates
print "releasestart:", Hnc.releasestart
print "releaseend:", Hnc.releaseend
print "releasetimes:", Hnc.releasetimes
print "species:", Hnc.species
print "FD:", Hnc.FD
print "FD[(0,'20100518210000')].species", Hnc.FD[(0,'20100518210000')].species
#print "FD[(0, '20100518210000')].grid:", Hnc.FD[(0, '20100518210000')].grid
# print "FD[(0, '20100518210000')].itime:", Hnc.FD[(0, '20100518210000')].itime
# print "FD[(0, '20100518210000')].timestamp:", Hnc.FD[(0, '20100518210000')].timestamp
# print "FD[(0, '20100518210000')].rel_i:", Hnc.FD[(0, '20100518210000')].rel_i
C = Hnc.C
print "C:", C
print "C[(0,1)].grid:", C[(0,1)].grid
print ""

# print "Calling fill_backward():"
# H.fill_backward(nspec=(0,))

# # H.C should be available by now
# print "H.C.keys():"
# print H.C[(0,2)].keys()

# # H.FD should be available by now
# print "H.FD.keys():"
# print H.FD[(0, '20070121220000')].keys()

# print "Calling read_grid():"
# FD = conv.read_grid(H, time_ret=0,nspec_ret=0)

# T = conv.read_trajectories(H)
# print "T.keys():"
# print T.keys()

# # Backward Runs
# #
# H = conv.Header(rf.datasets['Bwd1_V9.02'])
# print H.keys()

# print "Calling fill_backward():"
# H.fill_backward(nspec=(0,))

# # H.C should be available by now
# print "H.C.keys():"
# print H.C[(0,0)].keys()

# # H.FD should be available by now
# print "H.FD.keys():"
# print H.FD[(0, H.available_dates[0])].keys()

# print "Calling read_grid():"
# FD = conv.read_grid(H, time_ret=0,nspec_ret=0)

0 comments on commit aac162e

Please sign in to comment.