[ncl-talk] urgent issue about reading time series in each subarea of a shapefile
Mary Haley
haley at ucar.edu
Thu Nov 29 10:09:23 MST 2018
In the future, it would help if you tell us what you mean by the files
being wrong. I had to run your script and look at different variables in
order to determine what exactly was wrong.
It looks your "pmask" variable is all missing in each of the output files.
It gets calculated correctly with these lines:
;---Create masked data array
pmask = where(oxygen.eq.1,f,f at _FillValue)
copy_VarMeta(f,pmask)
But then later, before "pmask" is written to a NetCDF file, it is reset to
a 4D array with missing values with this line:
pmask=new((/1,1,nlat,nlon/), float)
pmask is never repopulated with values, and hence when it is written to the
file it is all missing.
I think what you meant to do was convert pmask to a 4D array, where time
and depth each have one dimension, and then copy the 2D pmask to this new
4D pmask array, correct?
If so, then instead of the "new" command, you should create a new variable,
say "pmask4d", as follows:
pmask4d = reshape(pmask,(/1,1,nlat,nlon/))
copy_VarAtts(pmask,pmask4d) ; IMPORTANT, YOU MAY WANT TO ADJUST SOME
; ATTRIBUTES BEFORE WRITING TO FILE
pmask4d!0 = "time"
pmask4d!1 = "depth"
pmask4d!2 = "latitude"
pmask4d!3 = "longitude"
pmask4d&time = time
pmask4d&depth = lev
pmask4d&latitude = lat
pmask4d&longitude = lon
and then change "pmask" to "pmask4d" in all the code that follows that
writes stuff to the file. For example:
filevardef(fout, "pmask" ,typeof(pmask4d) ,getvardims(pmask4d))
filevarattdef(fout,"pmask",pmask4d)
fout->pmask = (/pmask4d/)
I've attached a modified version of your script.
--Mary
On Thu, Nov 29, 2018 at 5:39 AM Amal Inge <amalingenieur89 at gmail.com> wrote:
> i want to have a time series from an ncfile (bbio.nc attached) for each
> subarea of a shapefilen(pic and zip attached)
> i tried the script attached newtest.ncl to do the mask and produce ncfile
> output for each time step
> but i get wrong ncfiles
> could you help please?
>
>
> bbio.nc
> <https://drive.google.com/file/d/1B0Y5bU6_hMcdYROmP4p-BJoGHUxo9FDH/view?usp=drive_web>
> _______________________________________________
> 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/20181129/23d824dc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newtest_mod.ncl
Type: application/octet-stream
Size: 10655 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181129/23d824dc/attachment.obj>
More information about the ncl-talk
mailing list