[ncl-talk] Help required to add a variable to geogrid file using NCL

ali mughal mughalali655 at gmail.com
Wed May 5 02:10:31 MDT 2021


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210505/5a1766d2/attachment.html>


More information about the ncl-talk mailing list