[ncl-talk] Help required to add a variable to geogrid file using NCL
Dennis Shea
shea at ucar.edu
Wed May 5 07:16:56 MDT 2021
; WRF_input_worstcase.csv
; 1st 3 lines
; cell
ID,Longtiude,Latitude,H1,H2,H3,H4,H5,H6,H7,H8,H9,H10,H11,H12,H13,H14,H15,H16,H17,H18,H19,H20,H21,H22,H23,H24
; 0,103.551796,1.187599182,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
; 1,103.551796,1.190299988,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dir_csv = "./"
fil_csv = "WRF_input_worstcase.csv"
pth_csv = dir_csv+fil_csv
ncol = 28
data = *readAsciiTable*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/readAsciiTable.shtml>(pth_csv,
ncol, "float", 1) ; <== maybe double wood be better
printVarSummary(data)
cell = *toint*( data(:,0) )
LON = data(:,1)
LAT = data(:,2)
H1 = data(:,3)
; :
H24 = data(:,27)
On Wed, May 5, 2021 at 2:11 AM ali mughal via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:
>
> Dear All
>
> I am using the following script to convert the data contained in this (
> https://we.tl/t-lS4dhtyDs4) csv file to add as a 3 dimensional variable
> to geo_em.d01.nc.
>
> filename = "WRF_input_worstcase.csv"
> a=addfile("../wrfout_d05_2016-03-31_00:00:00.nc","w") ; I am adding this
> file only to import structure of variable with W/m^2
> ac_heat=a->SF_AC_URB3D
> lines = asciiread(filename,-1,"string")
> nlines = dimsizes(lines)-1
> ncols = dimsizes(str_split(lines(0),","))
> nrows = dimsizes(lines)
>
> print("This file has " + nrows + " rows and " + ncols + " columns.")
>
> This file has 27091 rows and 27 columns.
>
> lat = str_get_field(lines , 2, ",")
> lon = str_get_field(lines , 1, ",")
>
> lat := stringtofloat(lat)
> lon := stringtofloat(lon)
>
> sh= traffic=readAsciiTable(filename, 24, "float", 1) *I
> want to read 24 columns here from H1-H24 but instead it selects the first
> 24 columns. The structure of the file should be latxlonx24*
> f = addfile("geo_em.d01.nc","w")
>
> sh at long_name = "sensible heat flux"
> sh at short_name = "heat flux"
> sh at units = "W/m^2"
> filevardef(a, "SH_FLUX", typeof(ac_heat), getvardims(ac_heat))
> f->SH_FLUX = sh
>
> I would be really grateful for help.
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210505/56d4def7/attachment.html>
More information about the ncl-talk
mailing list