[ncl-talk] [EXT]Re: Error in regridding Stage-4 data and writing NetCDF files

JETAL SUTARIYA jetal164 at email.arizona.edu
Sat Dec 4 11:34:59 MST 2021


Hi Rick,

Many thanks for your reply. The directory out was a wrong file and so it
was not saving files since directory did not exist.
Now, the script writes netcdf files but shows following error for one file:

Variable: le
Type: double
Total Size: 7900808 bytes
            987601 values
Number of Dimensions: 2
Dimensions and sizes:   [PRECIP_y | 881] x [PRECIP_x | 1121]
Coordinates:
            PRECIP_y: [23.117..53.51062]
            PRECIP_x: [-119.023..-80.74809]
Number Of Attributes: 1
  _FillValue :  -9999
(0)
(0)     min=0   max=6.802499999999999
warning:VarVarWrite: Dimension names for dimension number (0) don't match,
assigning name of rhs dimension to lhs and overwriting coordinate variable,
use "(/../)" if this change is not desired
warning:["Execute.c":8637]:Execute: Error occurred at or near line 35 in
file Regrid_stage4tonldas.ncl

warning:VarVarWrite: Dimension names for dimension number (0) don't match,
assigning name of rhs dimension to lhs and overwriting coordinate variable,
use "(/../)" if this change is not desired
warning:["Execute.c":8637]:Execute: Error occurred at or near line 36 in
file Regrid_stage4tonldas.ncl


Variable: flh
Type: double
Total Size: 831488 bytes
            103936 values
Number of Dimensions: 2
Dimensions and sizes:   [lat | 224] x [lon | 464]
Coordinates:
            lat: [25.0625..52.9375]
            lon: [-124.9375..-67.0625]
Number Of Attributes: 3
  long_name :   Precipitation
  unit :        mm/hr
  _FillValue :  -9999
(0)
(0)     Precipitation (mm/hr) : min=0   max=5.661505419668979
warning:VarVarWrite: rhs has no coordinate variable for dimension number
(0), destroying coordinate var,  use "(/../)" if this is not desired outcome
warning:VarVarWrite: rhs has no coordinate variable for dimension number
(1), destroying coordinate var,  use "(/../)" if this is not desired outcome
warning:["Execute.c":8637]:Execute: Error occurred at or near line 14 in
file Regrid_stage4tonldas.ncl

Unsure of why it shows this error and how to fix it?

Thanks,
Jetal

On Sat, Dec 4, 2021 at 10:53 AM Rick Brownrigg <brownrig at ucar.edu> wrote:

> *External Email*
> 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/3d06f852/attachment.html>


More information about the ncl-talk mailing list