Questions for NCL in adding spatial reference information

From: 김미애 <toa0710_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 18 2013 - 17:38:45 MST

Hello,

I want to do weighted average for 8-day MODIS data to monthly averaged data.
My code works and I got all the results files, but I have a message as below.Furthermore, I want to add spatial reference information into the final result.How can I add spatial reference information? After error message, there is my code.
Thank you
================== Error message ==================================warning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been definedwarning:Dimension (0) has not been defined
Variable: avg1Type: floatTotal Size: 5760000 bytes 1440000 valuesNumber of Dimensions: 2Dimensions and sizes: [YDim_MODIS_Grid_8Day_1km_LST | 1200] x [XDim_MODIS_Grid_8Day_1km_LST | 1200]Coordinates: Number Of Attributes: 13 _FillValue : 0 long_name : 8-day daytime 1km grid Land-surface Temperature units : K Number_Type : uint16 valid_range : ( 7500, 65535 ) LST : LST data * scale_factor scale_factor : 0.02 scale_factor_err : 0 add_offset : 0 add_offset_err : 0 calibrated_nt : 0 hdf_name : LST_Day_1km average_op_ncl : dim_avg_wgt_n function was applied===========================================================================
==================== My code ===============================================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 lonhe2_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[:]-&gt;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 &amp; latitude data@lat2d=he2_file[0]-&gt;GridLat_MODIS_Grid_8Day_1km_LST data@lon2d=he2_file[0]-&gt;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)
printVarSummary(avg1)exit;system("rm modis_lst.nc")fout=addfile("lst_mon1.nc","c")fout-&gt;lst=avg1fout=addfile("lst_mon2.nc","c")fout-&gt;lst=avg2fout=addfile("lst_mon3.nc","c")fout-&gt;lst=avg3fout=addfile("lst_mon4.nc","c")fout-&gt;lst=avg4fout=addfile("lst_mon5.nc","c")fout-&gt;lst=avg5fout=addfile("lst_mon6.nc","c")fout-&gt;lst=avg6fout=addfile("lst_mon7.nc","c")fout-&gt;lst=avg7fout=addfile("lst_mon8.nc","c")fout-&gt;lst=avg8fout=addfile("lst_mon9.nc","c")fout-&gt;lst=avg9fout=addfile("lst_mon10.nc","c")fout-&gt;lst=avg10fout=addfile("lst_mon11.nc","c")fout-&gt;lst=avg11fout=addfile("lst_mon12.nc","c")fout-&gt;lst=avg12end========================================================
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
Received on Wed Dec 18 17:38:59 2013

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