[ncl-talk] how to read off multiple variables from a nc file through one reading operation within a loop
Karin Meier-Fleischer
meier-fleischer at dkrz.de
Thu Oct 25 07:33:13 MDT 2018
Hi Tabish,
Krishan is right but I want to add something about the use of script variables.
If you define
>> var = "E_PM25J"
you have to use var with $...$
>> pm25 = a->$var$(0,0,:,:)
Bye, Karin
> Am 25.10.2018 um 15:21 schrieb Krishnamoorthy Chandramouli <chandrakrishna.90 at gmail.com>:
>
> 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:
>>
>> begin
>> a=addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/wrfchemi_00z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc","r")
>> pm25 = a->E_PM25J(0,0,:,:)
>> ("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
> _______________________________________________
> 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/5a9f6ad0/attachment.html>
More information about the ncl-talk
mailing list