Skip to content
Snippets Groups Projects
Commit 6ebe6c9b authored by Peters, Wouter's avatar Peters, Wouter
Browse files

back to pyhdf for now

parent bbdb863c
Branches
No related tags found
No related merge requests found
...@@ -107,32 +107,47 @@ class CtObservations(object): ...@@ -107,32 +107,47 @@ class CtObservations(object):
Note that this routine was not yet ported to Nio because it cannot read string arrays !!! Note that this routine was not yet ported to Nio because it cannot read string arrays !!!
""" """
import pyhdf.SD as HDF
import Nio import Nio
import datetime as dtm import datetime as dtm
from string import strip, join from string import strip, join
ncf = Nio.open_file(self.ObsFilename) ncf = HDF.SD(self.ObsFilename)
idates = ncf.variables['date_components'].get_value() idates = ncf.select('date_components').get()
ids = ncf.variables['id'].get_value() ids = ncf.select('id').get()
#sites = ncf.variables['site'].get_value() sites = ncf.select('site').get()
#sites = [s.tostring().lower() for s in sites] sites = [s.tostring().lower() for s in sites]
#sites = map(strip,sites) sites = map(strip,sites)
sites = map(str,range(len(ids))) lats = ncf.select('lat').get()
lats = ncf.variables['lat'].get_value() lons = ncf.select('lon').get()
lons = ncf.variables['lon'].get_value() alts = ncf.select('alt').get()
alts = ncf.variables['alt'].get_value() obs = ncf.select('obs').get()
obs = ncf.variables['obs'].get_value() species = ncf.select('species').get()
#species = ncf.variables['species'].get_value() date = ncf.select('date').get()
species = map(str,range(len(ids))) window = ncf.select('sampling_strategy').get()
date = ncf.variables['date'].get_value() flags = ncf.select('NOAA_QC_flags').get()
#window = ncf.variables['sampling_strategy'].get_value() flags = [s.tostring().lower() for s in flags]
window = map(str,range(len(ids))) flags = map(strip,flags)
#flags = ncf.variables['NOAA_QC_flags'].get_value() dummy = ncf.end()
#flags = [s.tostring().lower() for s in flags]
#flags = map(strip,flags) #+ ncf = Nio.open_file(self.ObsFilename)
flags = map(str,range(len(ids))) #+ idates = ncf.variables['date_components'].get_value()
dummy = ncf.close() #+ ids = ncf.variables['id'].get_value()
#+ sites = ncf.variables['site'].get_value()
#+ sites = [s.tostring().lower() for s in sites]
#+ sites = map(strip,sites)
#+ lats = ncf.variables['lat'].get_value()
#+ lons = ncf.variables['lon'].get_value()
#+ alts = ncf.variables['alt'].get_value()
#+ obs = ncf.variables['obs'].get_value()
#+ species = ncf.variables['species'].get_value()
#+ date = ncf.variables['date'].get_value()
#+ window = ncf.variables['sampling_strategy'].get_value()
#+ flags = ncf.variables['NOAA_QC_flags'].get_value()
#+ flags = [s.tostring().lower() for s in flags]
#+ flags = map(strip,flags)
#+ dummy = ncf.close()
msg = "Successfully read data from obs file (%s)"%self.ObsFilename ; logging.debug(msg) msg = "Successfully read data from obs file (%s)"%self.ObsFilename ; logging.debug(msg)
dates = [dtm.datetime(*d) for d in idates] dates = [dtm.datetime(*d) for d in idates]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment