[ncl-talk] how to read off multiple variables from a nc file through one reading operation within a loop

Krishnamoorthy Chandramouli chandrakrishna.90 at gmail.com
Thu Oct 25 07:21:20 MDT 2018


Hi,

You can use *getfilevarnames to read the variable names from nc file .*
*Loop over the names and read them.*


*Warm regards,*
*krishna*



On Thu, Oct 25, 2018 at 6:46 AM Tabish Ansari <tabishumaransari at gmail.com>
wrote:

> Hi,
>
> I want to read in several variables, in my case emissions of chemical
> species, from a netcdf file.
>
> There are too many variables in the file, eg- E_PM25I, E_PM25J, E_CO,
> E_NO2 etc
> Is it possible to store them in a string array and supply them one by one
> to the reading function?
>
> Currently, I'm unable to do this due to datatype mismatch.
>
> I'm trying something like this:
>
>
>
>
>
>
>
>
> *begina=addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/wrfchemi_00z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc
> <http://wrfchemi_00z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc>","r")pm25
> = a->E_PM25J(0,0,:,:)print("var read in the normal way")var = "E_PM25J"pm25
> = a->var(0,0,:,:)print("var read in dynamic way")end*
>
> however, the string variable var isn't used in the reading process.
>
> Please let me know if there's a way in NCL to do this.
> This will make the algorithm much more efficient.
>
> Cheers,
>
> Tabish
>
> Tabish U Ansari
> PhD student, Lancaster Environment Center
> Lancaster Univeristy
> Bailrigg, Lancaster,
> LA1 4YW, United Kingdom
> _______________________________________________
> 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/20181025/462758e9/attachment.html>


More information about the ncl-talk mailing list