Code Monkey home page Code Monkey logo

oco_vistool's People

Contributors

aronnem avatar tkach940 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

oco_vistool's Issues

Change Lite file reader to use netCDF4 instead of h5py

I noted that the variable metadata in the Lite SIF files is stored in attributes in a way that h5py fails to read it. Right now the error is caught by a try/except statement, the result is that when you plot a Lite SIF variable, the units and long_name are just not loaded. Since these are netCDF4 format, switching the reader to netCDF4 instead of h5py will allow the metadata to be read from the files.

Here's an example from ipython:

In [18]: import h5py, netCDF4
In [19]: litefile = '/data/OCO2_product/OCO2_L2_Lite_SIF.8r/2017/oco2_LtSIF_170101_B8100r_171012011053s.nc4'
In [20]: with h5py.File(litefile,'r') as h5:
    ...:     print(h5['SIF_757nm'].attrs.get('unit')) 
    ...:
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-20-c6d9a9a57b05> in <module>
      1 with h5py.File(litefile,'r') as h5:
----> 2     print(h5['SIF_757nm'].attrs.get('unit'))
      3 

~/miniconda3/envs/vistools/lib/python3.6/_collections_abc.py in get(self, key, default)
    658         'D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.'
    659         try:
--> 660             return self[key]
    661         except KeyError:
    662             return default

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

~/miniconda3/envs/vistools/lib/python3.6/site-packages/h5py/_hl/attrs.py in __getitem__(self, name)
     79 
     80         arr = numpy.ndarray(shape, dtype=dtype, order='C')
---> 81         attr.read(arr, mtype=htype)
     82 
     83         if len(arr.shape) == 0:

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5a.pyx in h5py.h5a.AttrID.read()

h5py/_proxy.pyx in h5py._proxy.attr_rw()

OSError: Unable to read attribute (no appropriate function for conversion path)

In [21]: with netCDF4.Dataset(litefile, 'r') as nc:
    ...:     print(nc['SIF_757nm'].unit)
    ...:
W/m2/sr/µm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.