[ncl-talk] Error in regridding Stage-4 data and writing NetCDF files
Rick Brownrigg
brownrig at ucar.edu
Sat Dec 4 10:52:55 MST 2021
Hi,
Are you certain that file does not already exist? The error message you
are getting is one that results when using addfile() with "c" mode and the
file already exists; ex:
$ touch foo.nc
$ Copyright (C) 1995-2019 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 6.6.2
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
ncl 0> f=addfile("foo.nc","c")
fatal:Could not create (foo.nc)
ncl1>
Rick
On Sat, Dec 4, 2021 at 1:30 AM JETAL SUTARIYA via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:
> Hi NCL Community,
>
> I am trying to regrid the NCEP 4 km Stage-4 data to NLDAS grid (1/8th
> degree). But, I get error while writing netcdf files output.
> Error: fatal:Could not create (/20150101.nc)
>
> I have attached few files here: 1) ncl script that I used to complete this
> task, 2) Screenshots of the PrintVarSummary error, printminmax, and ncdump
> of Stage-4 file and NLDAS file.
>
> Any suggestions are helpful.
> Thanks,
> Jetal
> Below is the script:
> ;This script converts Stage-4 PRECIP data to NLDAS data grid
> begin
> diri= "./"
> fili = systemfunc("cd "+diri+" ; ls *.nc")
> print(fili) ; all file names
> nfili = dimsizes(fili)
> print(nfili)
> do nf=0, nfili-1
> a = addfile(diri+fili(nf),"r") ; Read all Stage-4 data files
> b = addfile("201907.nc", "r") ; Read one file with NLDAS data grid
> lat/lon
>
> le = a->PRECIP(:,:)
> if(any(isnan_ieee(le))) then
> le at _FillValue = -9999
> replace_ieeenan(le,le at _FillValue,0)
> end if
> le!0 = "PRECIP_y"
> le&PRECIP_y = a->LAT(:,0)
> le!1 = "PRECIP_x"
> le&PRECIP_x = a->LON(0,:)
>
> printVarSummary(le)
> printMinMax(le, 1)
>
> lat = b->lat
> lon = b->lon
>
> lon!0 = "lon"
> lon at long_name = "longitude"
> lon at units = "degrees_east"
> lon&lon = lon
> lat!0 = "lat"
> lat at long_name = "latitude"
> lat at units = "degrees_north"
> lat&lat = lat
>
> flh = linint2_Wrap(le&PRECIP_x, le&PRECIP_y, le, False, lon, lat, 0)
> printVarSummary(flh)
> printMinMax(flh, 1)
>
> flh at unit = "mm/hr"
> flh at long_name = "Precipitation"
> flh!0 = "lat"
> flh&lat = lat
> flh!1 = "lon"
> flh&lon = lon
>
> dimNames = (/"lat","lon"/)
> dimSizes = (/dimsizes(lat),dimsizes(lon)/)
> dimUnlim = (/False,False/)
>
> diroutt = "../"
> iy = 2
> yyyy = 2015
> do mm = 1,12
> do dd = 1,iy
> if (mm .eq. 1) .or. (mm .eq. 3) .or. (mm .eq. 5) .or. (mm
> .eq. 7) .or. (mm .eq. 8) .or. (mm .eq. 10) .or. (mm .eq. 12) then
> iy = 31
> else if (mm .eq. 4) .or. (mm .eq. 6) .or. (mm .eq. 9) .or.
> (mm .eq. 11) then
> iy = 30
> else if (mod(yyyy,4) .eq. 0) then
> iy = 29
> else
> iy = 28
> end if
> end if
> end if
> if (dd .lt. 10)
> date = "0" + dd
> else
> date = dd
> end if
> if (mm .lt. 10)
> month = "0" + mm
> else
> month = mm
> end if
>
> filoutt = yyyy + month + date + ".nc"
> system("rm -f "+diroutt+filoutt)
> foutt= addfile(diroutt+filoutt,"c")
> setfileoption(foutt,"DefineMode",True)
> filedimdef(foutt,dimNames,dimSizes,dimUnlim)
>
> foutt->lat = lat
> foutt->lon = lon
> foutt->PRECIP = flh
> end do
> end do
> end do
> end
> _______________________________________________
> 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/20211204/780c3d0f/attachment.html>
More information about the ncl-talk
mailing list