Re: Re: HDF file processing

From: David Ian Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 12 Jun 2007 11:47:15 -0600

Hi Lin.

My guess is that 'XDim_mod08' and 'YDim_mod08' are dimensions but not
coordinate variables, which would lead to the sort of error you
describe.

You can prove this theory to yourself with the following code:

f = addfile("<filename>","r")
printFileVarSumary(f,"Optical_Depth_Land_And_Ocean_Mean")

You will probably see something like:

Number of Dimensions: 2
Dimensions and sizes: [YDim_mod08 | 180] x [XDim_mod08 | 360]
Coordinates:
             YDim_mod08: not a coordinate variable
             XDim_mod08: not a coordinate variable

If your file is like the sample MODIS file that I have, there are some
coordinate variables.
They just do not follow the convention of having the same name as the
dimensions.
If you are lucky you will find variables in the file named simply XDim
and YDim.

In which case you can modify your code as follows:

aod33&lat = f->YDim
aod33&lon = f->XDim

Hope this helps.
  -dave

On Jun 12, 2007, at 8:49 AM, Lin Su wrote:

> Sorry for the repeat:) Here is the header for the variable in HDF file:
> -------------------------------------------------------
> short Optical_Depth_Land_And_Ocean_Mean ( YDim_mod08, XDim_mod08 )
> valid_range : <ARRAY>
> _FillValue : -9999
> long_name : Aerosol Optical Thickness at 0.55 microns for
> both Ocean (best) and Land (corrected): Mean
> units : none
> scale_factor : 0.001
> add_offset : 0
> Level_2_Pixel_Values_Read_As : Real
> Derived_From_Level_2_Data_Set :
> Optical_Depth_Land_And_Ocean
> Included_Level_2_Nighttime_Data : False
> Quality_Assurance_Data_Set : None
> Statistic_Type : Simple
> Aggregation_Data_Set : None
> hdf_name : Optical_Depth_Land_And_Ocean_Mean
> -------------------------------------------------------------
> Thanks again,
> Lin
>
> ---- Original message ----
>> Date: Tue, 12 Jun 2007 08:41:08 -0600 (MDT)
>> From: Lin Su <sul_at_Colorado.EDU>
>> Subject: HDF file processing
>> To: ncl-talk_at_ucar.edu
>>
>> Dear NCL users,
>>
>> I am trying to read in the existing HDF file (MODIS data), and then
>> plot the contour map. However, it always showed that there is error
>> in these two sentences, and I know this is the key issue for that I
>> couldn't get the plot:
>> ----------------------------------
>> aod33&lat = Optical_Depth_Land_And_Ocean_Mean&YDim_mod08
>> aod33&lon = Optical_Depth_Land_And_Ocean_Mean&XDim_mod08
>> ---------------------------------------------------------
>>
>> Also, attached please find the whole scripts for read-in HDF data:
>> -------------------------------------------------
>> 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/shea_util.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>
>> begin
>>
>> ;=================================================
>> ; open history files and read in data
>> ;=================================================
>>
>> path = "/Volumes/Data/Models/cam/AOD/modis/col5/"
>> FileHandle = path + "*D3*94*.hdf"
>> files = systemfunc("ls " + FileHandle)
>> hists = addfiles(files, "r")
>> aod3=addfiles_GetVar(hists, files,
>> "Optical_Depth_Land_And_Ocean_Mean")
>> printVarSummary(aod3)
>> dims = dimsizes(aod3)
>> ; get the dimension of the history files
>> nlat = dims(0)
>> nlon = dims(1)
>>
>> aod33 = new((/nlat,nlon/),"float")
>> aod33!0 = "lat"
>> aod33!1 = "lon"
>> aod33_at_units = ""
>> aod33_at_name = "Dust Optical Depth"
>>
>> aod33&lat = Optical_Depth_Land_And_Ocean_Mean&YDim_mod08
>> aod33&lon = Optical_Depth_Land_And_Ocean_Mean&XDim_mod08
>> ;aod33&lat = Optical_Depth_Land_And_Ocean_Mean&YDim
>> ;aod33&lon = Optical_Depth_Land_And_Ocean_Mean&XDim
>>
>> lat = aod33&lat
>> lon = aod33&lon
>>
>> aod33_at_long_name = "MODIS"
>> aod33_at_units = ""
>>
>> aod33 = 0.001*aod3
>> ;=================================================
>> ; create plots
>> ;=================================================
>> ....
>> ---------------------------------------------------------
>>
>> Could anybody kindly take a look at the scripts and tell me the
>> incorrect coding?
>>
>> Thanks a bunch,
>> -Lin
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jun 12 2007 - 11:47:15 MDT

This archive was generated by hypermail 2.2.0 : Thu Jun 14 2007 - 09:39:54 MDT