[ncl-talk] ut_inv_calendar

Kyle Griffin ksgriffin2 at wisc.edu
Fri Feb 27 06:19:47 MST 2015


Conrado,

Please read your error messages more carefully! They tell you exactly what
is going wrong. In this case, it tells me that you did not spell the "cd"
part of the function name correctly...fix that so the name is as Dennis
suggested and let us know how that goes.

Kyle
On Feb 27, 2015 6:58 AM, <jorge.conrado at cptec.inpe.br> wrote:

>
>
>
>       Hi,
>
>       I don't have experience with the NCL and I downloaded a script
> (IR_download_and_crop.ncl) in the Web to download images from the ftp
> address:
>
>
>       ftp://disc2.nascom.nasa.gov/data/s4pa/TRMM_ANCILLARY/MERG/
>
>
>       This the script:
>
>
>
>
> ;########## IR_download_and_crop.ncl #############
> ;# This program downloads data from the NASA Merged IR database and crops
> to
> ;# the specified region and time period. A NETCDF file of the data is made
> ;# and the orignial fortran binary data is deleted.
>
> ;# 1. Set inital variables
> ;# 2. Read in 5 days of data over W. Africa write to NETCDF at 4km, 30 min
>
> 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/skewt_func.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> ;######## SET INITIAL VARS ########
>
> ;# Reference information for the Merged IR Dataset
> ;# For 2006...
> ;# Jul begins on day 182 and ends on 212
> ;# Aug begins on day 213 and ends on 243
> ;# Sep begins on day 244 and ends on 273
>
> ;# Set intital string variables
> hr=(/"00","01","02","03","04","05","06","07","08","09","10",
> "11","12","13","14","15","16","17","18","19","20","21","22","23"/)
>
> day_31=(/"01","02","03","04","05","06","07","08","09","10","
> 11","12","13","14","15","16","17","18","19","20","21","22","
> 23","24","25","26","27","28","29","30","31"/)
>
> day_30=(/"01","02","03","04","05","06","07","08","09","10","
> 11","12","13","14","15","16","17","18","19","20","21","22","
> 23","24","25","26","27","28","29","30"/)
>
> time_array=new((/240/),"double")
>
> time_array at units = "hours ref 1-1-1 00:00:0.0"
>
> ;# For the July brightness temp. array a byte array is storred to reduce
> memory requirements and storage space.
> ;# Convert to another data type and add 75.
>
> tb_array=new((/240,825,1925/),"float")
>
> ;######## Begin the time loop ########
>
> beg=15
>
> do day_ind=0,4
>    do hr_ind=0,23
>
>    file_name_download = "ftp://disc2.nascom.nasa.gov/
> data/s4pa/TRMM_ANCILLARY/MERG/2006/"+(beg+day_ind+182)+"/
> merg_200607"+day_31(beg+day_ind)+hr(hr_ind)+"_4km-pixel.Z"
>    system("wget "+file_name_download)
>
> ;####### READ THE FORTRAN BINARY ##############
>
>    file_name_read_zip = "merg_200607"+day_31(beg+day_
> ind)+hr(hr_ind)+"_4km-pixel.Z"
>    file_name_read = "merg_200607"+day_31(beg+day_
> ind)+hr(hr_ind)+"_4km-pixel"
>
>    print(file_name_read)
>
>    system("gunzip "+file_name_read_zip)
>
>    ;# Set Fortran read options
>
>    setfileoption("bin","ReadByteOrder","LittleEndian")
>    ir_temp   = byte2flt(fbindirread (file_name_read ,0,
> (/2,3298,9896/),"byte"))+75.
>
>    system("rm -f "+file_name_read)
>
> ;######## CROP THE IR GRID FOR WEST AFR #######
> ;# LARGE: 319.998E(8795)-59.97576E(1648),40.0013N(549)-19.9772S(2197)
> ;# LIMIT: 334.9874E(9207)-44.98637E(1236),25.00667N(961)-4.982578S(1785)
>
>    lon=fspan(0.0182,0.0182+0.036378335*9896,9896)
>    lat=fspan(59.982,59.982-0.036383683*3298,3298)
>
>    lon at units      = "degrees-east"
>    lat at units      = "degrees-north"
>
>    ir_temp!2    = "lon"
>    ir_temp!1    = "lat"
>    ir_temp!0    = "time"
>
>    ir_temp_re_0=new((/825,1925/),"float")
>    ir_temp_re_1=new((/825,1925/),"float")
>
>    ir_temp_re_0(:,:687)=ir_temp(lat|961:1785,lon|9207:9894,time|0)
>    ir_temp_re_0(:,688:)=ir_temp(lat|961:1785,lon|:1236,time|0)
>
>    ir_temp_re_1(:,:687)=ir_temp(lat|961:1785,lon|9207:9894,time|1)
>    ir_temp_re_1(:,688:)=ir_temp(lat|961:1785,lon|:1236,time|1)
>
>    lon_out = new((/1925/),"float")
>
>    lon_out(:687)=lon(9207:9894)
>    lon_out(688:)=lon(0:1236)
>
>    lat_out  = lat(961:1785)
>
> ;########## PLACE IN ARRAY #######
>
>    tb_array(48*day_ind+hr_ind*2,:,:)=ir_temp_re_0       ;# First half hour
>    tb_array(48*day_ind+hr_ind*2+1,:,:)=ir_temp_re_1     ;# Second half
> hour
>
> ;########## SET THE TIMES ########
>
>    time_array(48*day_ind+hr_ind*2) = ut_inv_calendar(2006,7,beg+
> day_ind+1,hr_ind+1,0,0,time_array at units, 0)
>    time_array(48*day_ind+hr_ind*2+1) = ut_inv_calendar(2006,7,beg+
> day_ind+1,hr_ind+1,30,0,time_array at units, 0)
>
>    end do
> end do
>
> ;######## CREATE THE NETCDF FILE ########
>
>    ntim  = 240
>    nlat  = 825
>    nlon  = 1925
>
>    diro = "./"                     ; Output directory
>    filo = "ir_test_jul_16_to_jul_20.nc"             ; Output file
>    system("/bin/rm -f " + diro + filo)    ; remove if exists
>    fout  = addfile (diro + filo, "c")  ; open output file
>
> ;===================================================================
> ; explicitly declare file definition mode. Improve efficiency.
> ;===================================================================
>
>    setfileoption(fout,"DefineMode",True)
>
> ;===================================================================
> ; create global attributes of the file
> ;===================================================================
>
>    fAtt               = True            ; assign file attributes
>    fAtt at title         = "NCL Efficient Approach to netCDF Creation"
>    fAtt at source_file   =  "original-file.nc"
>    fAtt at Conventions   = "None"
>    fAtt at creation_date = systemfunc ("date")
>    fileattdef( fout, fAtt )            ; copy file attributes
>
> ;===================================================================
> ; predefine the coordinate variables and their dimensionality
> ; Note: to get an UNLIMITED record dimension, we set the dimensionality
> ; to -1 (or the actual size) and set the dimension name to True.
> ;===================================================================
>
>    dimNames = (/"time", "lat", "lon"/)
>    dimSizes = (/ -1   ,  nlat,  nlon/)
>    dimUnlim = (/ True , False, False/)
>    filedimdef(fout,dimNames,dimSizes,dimUnlim)
>
> ;===================================================================
> ; predefine the the dimensionality of the variables to be written out
> ;===================================================================
> ; Here we are using NCL functions to facilitate defining
> ; each variable's dimension name(s) and type.
> ; The following could be replaced with explicit, user defined dimension
> ; names different from those associated with the variable in memory.
> ; Say, PS(time,lat,lon) in the NCL script. They could be redefined for the
> file via:
> ; filevardef(fout, "PS"   ,typeof(PS) ,(/"TIME","latitude","longitude"/))
> ;===================================================================
>
>    filevardef(fout, "time" ,(/"double"/),(/"time"/))
>    filevardef(fout, "lat"  ,(/"float"/),(/"lat"/))
>    filevardef(fout, "lon"  ,(/"float"/),(/"lon"/))
>    filevardef(fout, "TB"   ,(/"float"/),(/"time","lat","lon"/))
>
> ;===================================================================
> ; Copy attributes associated with each variable to the file
> ; All attributes associated with each variable will be copied.
> ;====================================================================
>
>    filevarattdef(fout,"time" ,time_array)              ; copy time
> attributes
>    filevarattdef(fout,"lat"  ,lat_out)                 ; copy lat
> attributes
>    filevarattdef(fout,"lon"  ,lon_out)                 ; copy lon
> attributes
>    filevarattdef(fout,"TB"   ,tb_array)                      ; copy PS
> attributes
>
> ;===================================================================
> ; explicitly exit file definition mode. **NOT REQUIRED**
> ;===================================================================
>
>    setfileoption(fout,"DefineMode",False)
>
> ;===================================================================
> ; output only the data values since the dimensionality and such have
> ; been predefined. The "(/", "/)" syntax tells NCL to only output the
> ; data values to the predefined locations on the file.
> ;====================================================================
>
>    fout->time   = (/time_array/)
>    fout->lat    = (/lat_out/)
>    fout->lon    = (/lon_out/)
>    fout->TB      = (/tb_array/)
>
> end
>
>
>
>      I run it and the script download the images, but this the line
>
>
>   time_array(48*day_ind+hr_ind*2) = ut_inv_calendar(2006,7,beg+
> day_ind+1,hr_ind+1,0,0,time_array at units, 0)
>    time_array(48*day_ind+hr_ind*2+1) =
>
>
>     I had the message:
>
>
> fatal:ut_inv_calendar: Invalid specification string
> fatal:["Execute.c":8578]:Execute: Error occurred at or near line 103 in
> file IR_download_and_crop.ncl
>
>
>
>      I already change the ut_inv_calendar to cd_inv_calendar but I had the
> same error.
>
>
> fatal:Undefined identifier: (cv_inv_calendar) is undefined, can't continue
> fatal:["Execute.c":8578]:Execute: Error occurred at or near line 103 in
> file IR_download_and_crop.ncl
>
>
>
>
> fatal:ut_inv_calendar: Invalid specification string
> fatal:["Execute.c":8578]:Execute: Error occurred at or near line 103 in
> file IR_download_and_crop.ncl
>
>
>     I don't know how can I solve this error.
>
>
>     Thank  for all that help me with the question I asked yesterday.
>
>
>     Conrado
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150227/e0850568/attachment.html 


More information about the ncl-talk mailing list