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

Karin Meier-Fleischer meier-fleischer at dkrz.de
Sat Jul 16 10:37:47 MDT 2016


Hi Gurbrinder,

please take a look at the addfiles function to read multiple files:

http://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml

Bye,
Karin

> Am 16.07.2016 um 17:10 schrieb gurbrinder aulakh <gurbrinderaulakh at yahoo.co.in>:
> 
> 
> 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)
>   
>  
>   
>   
>   
> end
> please help
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> 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/20160716/e8883cdc/attachment.html 


More information about the ncl-talk mailing list