[ncl-talk] creating daily files from hourly outputs
Karin Meier-Fleischer
meier-fleischer at dkrz.de
Fri Jan 19 05:50:13 MST 2018
Sorry, there is a typo
filelist = systemfunc("ls infile*.nc")
wrfin= addfiles(filelist,"r")
pres_pa = wrf_user_getvar(wrfin,"pres",-1)
t_k = wrf_user_getvar(wrfin,"tk",-1)
system("rm -rf "+file_out)
wrfpost = addfile(file_out,"c")
...
Am 19.01.18 um 13:49 schrieb Karin Meier-Fleischer via ncl-talk:
> Use addfiles to read all 24 files and select the variable which you
> want to write to the new file.
>
> Assume your 24 files are netCDF and their names start with 'infile':
>
> ...
> filelist = systemfunc("ls infile*.nc")
>
> f = addfiles(filelist,"r")
>
> pres_pa = wrf_user_getvar(wrfin,"pres",-1)
> t_k = wrf_user_getvar(wrfin,"tk",-1)
>
> system("rm -rf "+file_out)
> wrfpost = addfile(file_out,"c")
> ...
>
> -Karin
>
> Am 19.01.18 um 13:33 schrieb Noelia otero:
>> Hi Karin,
>>
>> Yes, I know..that's why I am not sure how I can do it. If I have 24
>> files for one day, I just wanted to extract some variables and
>> storage the daily values in one single file.
>> Is there any way? If I use system("rm -rf" +file_out) my file with
>> previous value is removed...so I would have a new file with the
>> current time, which I don't want.. any suggestion?
>>
>> Thanks!
>> Noelia
>>
>> 2018-01-19 13:30 GMT+01:00 Karin Meier-Fleischer via ncl-talk
>> <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>>:
>>
>> Hi Noelia,
>>
>> NCL can't create a new file when it already exits. You have to
>> make sure that the file doesn't exist or delete it before using
>> addfile.
>>
>> system("rm -rf "+file_out)
>> wrfpost = addfile(file_out,"c")
>>
>> -Karin
>>
>> Am 19.01.18 um 13:15 schrieb Noelia otero via ncl-talk:
>>> Hi all,
>>>
>>> I have hourly files from WRF and I wanted to create daily files
>>> (with the hourly outputs, Time=24). I was using addfile(,
>>> "c")....I know the error I got it is caused by "c", once the
>>> first file is created I can´t opened again..(If I am not wrong,
>>> right?) Is there any way to do it?
>>>
>>> print(file_in)
>>> ; wrfout_d01_2010-01-01_00:00:00.nc <http://00.nc>
>>> wrfin = addfile(file_in,"r")
>>>
>>> ; I want the output: file_out=met_wrfout_d01_2010-01-01.nc
>>> <http://met_wrfout_d01_2010-01-01.nc>
>>> wrfpost = addfile(file_out,"c") ;create new netCDF file
>>>
>>> pres_pa = wrf_user_getvar(wrfin,"pres",-1)
>>> t_k = wrf_user_getvar(wrfin,"tk",-1)
>>>
>>> wrfpost->t_k= t_k
>>> wrfpost->pres_pa= pres_pa
>>>
>>> Time = wrf_user_getvar(wrfin,"Times",-1)
>>> lat = wrf_user_getvar(wrfin,"lat",-1)
>>> lon = wrf_user_getvar(wrfin,"lon",-1)
>>>
>>> wrfpost->time = Time
>>> wrfpost->lat= lat
>>> wrfpost->lon= lon
>>>
>>>
>>> Thanks in advance,
>>> Best
>>> Noelia
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>>
>> --
>> Dipl. Geophys. Karin Meier-Fleischer
>> Visualization, NCL, CDO
>> Application Support
>>
>> Deutsches Klimarechenzentrum GmbH (DKRZ)
>> Bundesstrasse 45a - D20146 Hamburg - Germany
>>
>> Phone:+49 (0)40 460094 126 <tel:+49%2040%20460094126>
>> Fax:+49 (0)40 460094 270 <tel:+49%2040%20460094270>
>> E-Mail:meier-fleischer at dkrz.de <mailto:meier-fleischer at dkrz.de>
>> URL:www.dkrz.de <http://www.dkrz.de>
>>
>> Geschäftsführer: Prof. Dr. Thomas Ludwig
>> Sitz der Gesellschaft: Hamburg
>> Amtsgericht Hamburg HRB 39784
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> <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
--
Dipl. Geophys. Karin Meier-Fleischer
Visualization, NCL, CDO
Application Support
Deutsches Klimarechenzentrum GmbH (DKRZ)
Bundesstrasse 45a - D20146 Hamburg - Germany
Phone: +49 (0)40 460094 126
Fax: +49 (0)40 460094 270
E-Mail: meier-fleischer at dkrz.de
URL: www.dkrz.de
Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180119/cfd145c8/attachment.html>
More information about the ncl-talk
mailing list