Re: MODIS HDF

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue Aug 30 2011 - 12:11:50 MDT

HI Mike,
Change the lines:
npp@lat2d=lat2d
npp@lon2d=lon2d
to
 npp&lat2d = lat2d
 npp&lon2d = lon2d

You are trying to write 2d variables as attributes, which NetCDF does not allow. NCL should not be seg faulting though. We will look into this.
 -dave
   
On Aug 30, 2011, at 12:05 PM, Michael Notaro wrote:

> Thanks Dennis. Using hdfeof helps a lot and gives me the lats/lons now.
>
> Seems I am having another problem. After I read the hdfeos and retrieve
> the lats/lons and data, I tried writing it to a file and always get segmentation fault.
> What am I doing wrong?
>
>
>
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> begin
>
> ; 1km annual npp modis on 1200x1200 tiles
>
> a=addfile("/Users/notaro/downloads/Y2000/MOD17A3.A2000366.h11v11.305.2009342143541.hdf.hdfeos","r")
>
> lat2d=a->GridLat_MOD_Grid_MOD17A3
> lon2d=a->GridLon_MOD_Grid_MOD17A3
>
> npp=short2flt(a->Npp_1km_MOD_Grid_MOD17A3)
>
> npp!0="lat2d"
> npp!1="lon2d"
> npp@lat2d=lat2d
> npp@lon2d=lon2d
> npp@coordinates="lat2d lon2d"
> npp@projection="sinusoidal"
>
> printVarSummary(npp)
>
> out=addfile("test.nc","c")
> out->npp=npp
> out->lat2d=lat2d
> out->lon2d=lon2d
>
> end
>
>
>
>
>
>
>
> Variable: npp
> Type: float
> Total Size: 5760000 bytes
> 1440000 values
> Number of Dimensions: 2
> Dimensions and sizes: [lat2d | 1200] x [lon2d | 1200]
> Coordinates:
> Number Of Attributes: 7
> lon2d : <ARRAY of 1440000 elements>
> lat2d : <ARRAY of 1440000 elements>
> _FillValue : 1e+20
> coordinates : lat2d lon2d
> hdfeos_name : Npp_1km
> projection : sinusoidal
> unsigned : True
>
>
>
>
>
>
>
>
>
> On Aug 30, 2011, at 12:44 PM, Dennis Shea wrote:
>
>> Mike
>>
>> [1]
>> %> ncl_filedump MOD17A3.A2010365.h00v08.305.2011029145245.hdf
>>
>> yields
>>
>> Variable: f
>> Type: file
>> filename: MOD17A3.A2010365.h00v08.305.2011029145245
>> path: MOD17A3.A2010365.h00v08.305.2011029145245.hdf
>> file global attributes:
>> HDFEOSVersion : HDFEOS_V2.16
>> StructMetadata_0 : GROUP=SwathStructure
>> END_GROUP=SwathStructure
>> GROUP=GridStructure
>> GROUP=GRID_1
>> GridName="MOD_Grid_MOD17A3"
>> XDim=1200
>> YDim=1200
>> UpperLeftPointMtrs=(-20015109.354000,1111950.519667)
>> LowerRightMtrs=(-18903158.834333,0.000000)
>> Projection=GCTP_SNSOID
>> [SNIP]
>>
>> [2]
>> If you append the '.hdfeos' suffix, you will get that lat/lon values.
>>
>> %> ncl_filedump MOD17A3.A2010365.h00v08.305.2011029145245.hdf.hdfeos
>>
>> Variable: f
>> Type: file
>> filename: MOD17A3.A2010365.h00v08.305.2011029145245.hdf
>> path: MOD17A3.A2010365.h00v08.305.2011029145245.hdf
>> file global attributes:
>> dimensions:
>> YDim_MOD_Grid_MOD17A3 = 1200
>> XDim_MOD_Grid_MOD17A3 = 1200
>> variables:
>> double GridLat_MOD_Grid_MOD17A3 ( YDim_MOD_Grid_MOD17A3,
>> XDim_MOD_Grid_MOD17A3 )
>> projection : (null)
>> corners : ( 9.995833332438675, 9.995833332438675,
>> 0.004166666666293064, 0.004166666666293064 )
>> long_name : latitude
>> units : degrees_north
>>
>> double GridLon_MOD_Grid_MOD17A3 ( YDim_MOD_Grid_MOD17A3,
>> XDim_MOD_Grid_MOD17A3 )
>> projection : (null)
>> corners : ( 177.2297839752788, -172.6245418649626,
>> -170.00416710093, -179.9958337931229 )
>> long_name : longitude
>> units : degrees_east
>> [snip]
>>
>> [3] Use the hdfeos suffix. The names are different than using 'just' hdf
>> however NCL does provide the georeferenced data coordinates.
>>
>>
>> [4] You might look at:
>>
>> http://www.ncl.ucar.edu/Applications/binning.shtml
>>
>> Good luck
>> D
>>
>>
>>
>>
>> On 8/30/11 11:23 AM, Michael Notaro wrote:
>>> I am trying to work with MODIS HDF data of the land variable 1-km annual NPP (net primary productivity).
>>>
>>> ftp://ftp.ntsg.umt.edu/pub/MODIS/Mirror/MOD17_Science_2010/MOD17A3/
>>>
>>> Each file is on a separate tile. I put the info below on a sample file's
>>> info on the variable Npp_1km and the 1200x1200 grid and bounding rectangle.
>>>
>>> It is my understanding that I should grab the rectangles that overlap my study region,
>>> which is Wisconsin. I think 4 of them overlap it.
>>>
>>> I can read in the data with addfile (or use ncl_convert2nc). But I am not sure
>>> how to retrieve the proper lats/lons to plot the data correctly. I used short2flt also
>>> when reading it. I am guessing that the data grid must not be a normal rectangle but
>>> stretched as the satellite moves, since the range of the lats is 10 degrees but the
>>> range of the lons is 60 degrees.
>>>
>>> Any suggestions on how to plot this in NCL is appreciated.
>>>
>>> Michael
>>>
>>>
>>> YDim_MOD_Grid_MOD17A3 = 1200 ;
>>> XDim_MOD_Grid_MOD17A3 = 1200 ;
>>>
>>> short Npp_1km(YDim_MOD_Grid_MOD17A3, XDim_MOD_Grid_MOD17A3) ;
>>> Npp_1km:hdf_name = "Npp_1km" ;
>>> Npp_1km:units = "kg_C/m^2" ;
>>> Npp_1km:long_name = "MOD17A3 NPP--MODIS Gridded 1KM Annual Net Primary Productivity (NPP)" ;
>>> Npp_1km:_FillValue = -1s ;
>>> Npp_1km:valid_range = 0s, -36s ;
>>> Npp_1km:calibrated_nt = 23 ;
>>> Npp_1km:add_offset_err = 0. ;
>>> Npp_1km:add_offset = 0. ;
>>> Npp_1km:scale_factor_err = 0. ;
>>> Npp_1km:scale_factor = 0.0001 ;
>>>
>>> " OBJECT = NORTHBOUNDINGCOORDINATE\n",
>>> " NUM_VAL = 1\n",
>>> " VALUE = 69.9999999937138\n",
>>> " END_OBJECT = NORTHBOUNDINGCOORDINATE\n",
>>> "\n",
>>> " OBJECT = SOUTHBOUNDINGCOORDINATE\n",
>>> " NUM_VAL = 1\n",
>>> " VALUE = 59.9999999946118\n",
>>> " END_OBJECT = SOUTHBOUNDINGCOORDINATE\n",
>>> "\n",
>>> " OBJECT = EASTBOUNDINGCOORDINATE\n",
>>> " NUM_VAL = 1\n",
>>> " VALUE = -119.983333303015\n",
>>> " END_OBJECT = EASTBOUNDINGCOORDINATE\n",
>>> "\n",
>>> " OBJECT = WESTBOUNDINGCOORDINATE\n",
>>> " NUM_VAL = 1\n",
>>> " VALUE = -179.999999938971\n",
>>> " END_OBJECT = WESTBOUNDINGCOORDINATE\n",
>>> "\n",
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Aug 30 12:11:56 2011

This archive was generated by hypermail 2.1.8 : Wed Sep 07 2011 - 10:58:58 MDT