Re: Questions for NCL error message

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 18 2013 - 17:21:23 MST

When using addfiles you have to read variables off of the file with
different syntax as that used for addfile.
See: http://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml
And look for the section starting with this:
"The *addfiles* function differs from the *addfile*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml>
function in several ways: "
and take a look at section 3.

Thus, change this:
data@lat2d=he2_file->GridLat_MODIS_Grid_8Day_1km_LST
data@lon2d=he2_file->GridLon_MODIS_Grid_8Day_1km_LST
to this:
data@lat2d=he2_file[0]->GridLat_MODIS_Grid_8Day_1km_LST
data@lon2d=he2_file[0]->GridLon_MODIS_Grid_8Day_1km_LST
(the [0] syntax tells NCL to only access the first file listed in
he2_file_paths)

Hope that helps. If you have further questions please respond to the
ncl-talk email list.
Adam

On 12/18/13, 4:53 PM, 김미애 wrote:
>
> Hello,
>
> Thank you so much. I am having a problem.
>
> I added the extension ".he2" to the hdf filename, but I have an error
> message as below.
>
> *fatal:(he2_file) does not reference a file*
>
> *fatal:Execute: Error occurred at or near line 49 in file wgtavg1.ncl*
>
>
> What is the meaning of "does not reference a file"?
> The following is my changed code, and what am I wrong in the code?
>
> Thank you
>
> ==============================================================================
>
> eos_file_path="/MODIS/2009/h28v05/" ;Read file for the first time.
>
> eos_file_paths=systemfunc("ls "+eos_file_path+"MOD11A2.A2009*.hdf")
>
> eos_file=addfiles(eos_file_paths,"r")
>
> he2_file_path="/MODIS/2009/h28v05/" ;Read file for the second time to
> efficiently obtain lat and lon
>
> he2_file_paths=systemfunc("ls "+he2_file_path+"MOD11A2.A2009*.hdf")
>
> he2_file=addfiles(he2_file_paths+".he2","r")
>
> ;List available fields and attributes
>
> ;print(eos_file)
>
> ;Read data field
>
> data_raw=eos_file[:]->LST_Day_1km
>
> ;printVarSummary(data_raw)
>
> ;Filter out invalid values and set them as fill value.
>
> data_valid=where(data_raw.gt.data_raw@valid_range(0).and.data_raw.lt.data_raw@valid_range(1),
> data_raw, data_raw@_FillValue)
>
> ;Apply scale factor according to the field attribute
>
> ;correct_data_value=(raw_data_value-offset)*scale_factor
>
> data=(data_valid-data_raw@add_offset)*data_raw@scale_factor
>
> data@_FillValue=(data_raw@_FillValue-data_raw@add_offset)*data_raw@scale_factor
>
> data@long_name=data_raw@long_name
>
> data@units=data_raw@units
>
> ;Associate longitude & latitude
>
> data@lat2d=he2_file->GridLat_MODIS_Grid_8Day_1km_LST
>
> data@lon2d=he2_file->GridLon_MODIS_Grid_8Day_1km_LST
>
> dims= dimsizes(data_raw)
>
> ny=dims(0)
>
> nx=dims(1)
>
> nfile = ny/nx
>
> input=new((/nfile,nx,nx/),float)
>
> do i=0,nfile-1
>
> input(i,:,:)=data_raw(i*nx:i*nx+nx-1,:) ;t*x*y
>
> end do
>
> wgt1=(/1, 1, 1, 0.875/)
>
> wgt2=(/0.125, 1, 1, 1, 0.5/)
>
> wgt3=(/0.5, 1, 1, 1, 0.375/)
>
> wgt4=(/0.625, 1, 1, 1, 0.125/)
>
> wgt5=(/0.875, 1, 1, 1/)
>
> wgt6=(/1, 1, 1, 0.75/)
>
> wgt7=(/0.25, 1, 1, 1, 0.625/)
>
> wgt8=(/0.375, 1, 1, 1, 0.5/)
>
> wgt9=(/0.5, 1, 1, 1, 0.25/)
>
> wgt10=(/0.75, 1, 1, 1, 0.125/)
> wgt11=(/0.875, 1, 1, 0.875/)
> wgt12=(/0.125, 1, 1, 1, 0.75/)
>
> avg1=dim_avg_wgt_n_Wrap(input(0:3,:,:), wgt1, 1, 0)
> avg2=dim_avg_wgt_n_Wrap(input(3:7,:,:), wgt2, 1, 0)
> avg3=dim_avg_wgt_n_Wrap(input(7:11,:,:), wgt3, 1, 0)
> avg4=dim_avg_wgt_n_Wrap(input(11:15,:,:), wgt4, 1, 0)
> avg5=dim_avg_wgt_n_Wrap(input(15:18,:,:), wgt5, 1, 0)
> avg6=dim_avg_wgt_n_Wrap(input(19:22,:,:), wgt6, 1, 0)
> avg7=dim_avg_wgt_n_Wrap(input(22:26,:,:), wgt7, 1, 0)
> avg8=dim_avg_wgt_n_Wrap(input(26:30,:,:), wgt8, 1, 0)
> avg9=dim_avg_wgt_n_Wrap(input(30:34,:,:), wgt9, 1, 0)
> avg10=dim_avg_wgt_n_Wrap(input(34:38,:,:), wgt10, 1, 0)
> avg11=dim_avg_wgt_n_Wrap(input(38:41,:,:), wgt11, 1, 0)
> avg12=dim_avg_wgt_n_Wrap(input(41:45,:,:), wgt12, 1, 0)
>
> fout=addfile("lst_mon1.nc","c")
> fout->lst=avg1
> fout=addfile("lst_mon2.nc","c")
> fout->lst=avg2
> fout=addfile("lst_mon3.nc","c")
> fout->lst=avg3
> fout=addfile("lst_mon4.nc","c")
> fout->lst=avg4
> fout=addfile("lst_mon5.nc","c")
> fout->lst=avg5
> fout=addfile("lst_mon6.nc","c")
> fout->lst=avg6
> fout=addfile("lst_mon7.nc","c")
> fout->lst=avg7
> fout=addfile("lst_mon8.nc","c")
> fout->lst=avg8
> fout=addfile("lst_mon9.nc","c")
> fout->lst=avg9
> fout=addfile("lst_mon10.nc","c")
> fout->lst=avg10
> fout=addfile("lst_mon11.nc","c")
> fout->lst=avg11
> fout=addfile("lst_mon12.nc","c")
> fout->lst=avg12
> end
> =========================================================================
>
> Thank you so much again.
>
> Sincerely
>
> Miae
>
> -------------------------------------------------
> Miae Kim
> School of Urban and Environment Engineering
> Ulsan National Institute of Science and Technology (UNIST)
> UNIST-gil 50, Ulsan 689-798, South Korea
> Mobile: +82-10-9421-8287
> E-mail: toa0710@naver.com
>
>
>
> _______________________________________________
> 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 Wed Dec 18 17:21:41 2013

This archive was generated by hypermail 2.1.8 : Mon Jan 06 2014 - 13:02:23 MST