[ncl-talk] how to read different variable names from multiple files

gurbrinder aulakh gurbrinderaulakh at yahoo.co.in
Sat Jul 16 09:10:13 MDT 2016


I want to read u component of wind at different hpa level, variable names are like UGRD_500_ISBL,UGRD_800_ISBL and so on in multiple netcdf files. Can I read these different variable names from multiple .nc files at once......Please help...As otherwise I have to read one by one as in the following script.....

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"       ;       ;begin
f     = addfile("UwindComponent/uwind_850_600gmt.nc" , "r");all_files=systemfunc("uwind_850_600gmt.nc") glond =  f->longitude  glatd =  f->latitude 
    dq = str_get_dq() 
  latS   = 29.66       latN   = 34.66  lonW   = -85.40  lonE   = -80.40    ;printVarSummary(lonW)  ;printVarSummary(lonE)  
ji = region_ind(glatd,glond, latS, latN, lonW, lonE)
  jStrt = ji(0)      ; lat start  jLast = ji(1)      ; lat last  iStrt = ji(2)      ; lon start  iLast = ji(3)      ; lon last
  ;printVarSummary(jStrt)  ;print(jLast)  ;print(iStrt)  ;print(iLast)    LAT2D = glatd(jStrt:jLast,iStrt:iLast)  LON2D = glond(jStrt:jLast,iStrt:iLast)
; printVarSummary(LAT2D)  ;print(LON2D)
                      ; read data just for the region of interest  x = f->UGRD_500_ISBL(:,jStrt:jLast,iStrt:iLast);print(x)csv_filename="mydata.csv"fields=(/"LAT","LON","Temperature"/)  ; printVarSummary(LAT2D)fields=dq+fields+dq  header=[/str_join(fields,",")/]    alist=[/LAT2D,LON2D,x/]    format="%.2f,%.2f,%.2f"    system("rm -rf " + csv_filename)  write_table(csv_filename,"w",header,"%s")  write_table(csv_filename,"a",alist,format)         endplease help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160716/0a135c23/attachment.html 


More information about the ncl-talk mailing list