nctoolbox / nctoolbox

NCTOOLBOX A Matlab toolbox for working with common data model datasets
http://nctoolbox.github.io/nctoolbox
Other
129 stars 57 forks source link

uvariable is missing the `timeindexij` method #15

Open rsignell-usgs opened 10 years ago

rsignell-usgs commented 10 years ago

In the ugrid branch, the uvariable class is missing the timeindexij method that allows a user to figure out which time step corresponds to a specified date.

Until we have this method, we can't solve issue #5.

It looks like this is the NetCDF-Java method we should be using: http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/v4.2/javadoc/ucar/nc2/dataset/CoordinateAxis1DTime.html#findTimeIndexFromDate(java.util.Date)

rsignell-usgs commented 10 years ago

@hohonuuli, any chance you could take a look at this? I don't know enough about netcdf-java or the relationship between netcdf-java and matlab to fix this, and @acrosby is no longer in the environmental software business.

hohonuuli commented 10 years ago

Hey Rich (@rsignell-usgs), Yeah, I can take a peak at it. It's on my task list, I hope to get to it later today.

hohonuuli commented 10 years ago

Rich (@rsignell-usgs), I see that Dave (@daf) is working on this same issue. Do you know what the status of his patch is? Thanks

daf commented 10 years ago

@hohonuuli Rich and I were trying to hack something together yesterday in person, but it was quick and dirty and wasn't the real approach. We spoke with @blazetopher who had an idea of the correct approach but not sure what came out of that conversation as I was looking at other things at the time.

rsignell-usgs commented 10 years ago

Where we got to with @blazetopher was that the netcdfdataset should be accessible from within the ncugrid class, so it should be possible to access the netcdf java method that will return the time index. So that's when I pinged brian

hohonuuli commented 10 years ago

OK, I'm coming into this completely cold. Can someone spin me up on what timeindexij is, what do we use it for, some code snipped somewhere that can illuminate what I'm trying to accomplish? mucho gracias. @daf, @acrosby, @rsignell-usgs

hohonuuli commented 10 years ago

@rsignell-usgs OK, so in your example, zvar currently looks like this:

>> nc = ncugrid('http://testbedapps-dev.sura.org/thredds/dodsC/in/umass/fvcom/run/2005/withwaves');
>> zvar=nc.uvariable('zeta')

zvar = 

  ncuvariable with properties:

     dataset: [1x1 ncugrid]
    variable: [1x1 ucar.nc2.dt.ugrid.MeshVariable]
        name: 'zeta'
        axes: {3x1 cell}
        size: [745 5620]

Now that I have this zvar, you want to call zvar.timewindowij(???). What are the arguments to timewindowij? What do you want to get back from it?

rsignell-usgs commented 10 years ago

Yes, I guess the functionality should be the same as this: https://github.com/nctoolbox/nctoolbox/blob/master/cdm/ncgeovariable.m#L549

but as Alex says in his "TODO", there is definitely a better way to do this using NetCDF-Java, and that would be using http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/v4.2/javadoc/ucar/nc2/dataset/CoordinateAxis1DTime.html#findTimeIndexFromDate(java.util.Date)

hohonuuli commented 10 years ago

@rsignell-usgs @daf

I added some new methods to ncuvariable for retrieving the time variable. The new methods are gettimename, gettimevar, and gettimedata. Nothing fancy there, you guys were on the right track; they should work as expected now. I have not implemented timewindowij. I have to warp off to another project. Can you guys tackle the implementation of timewindowij?

p.s. The changes are in the ugrid branch.

rsignell-usgs commented 10 years ago

Awesome! The first two panels of the 3 plot comparison in #5 now work with ncugrid and uvariable ! 11-14-2013 6-26-13 pm