[ncl-talk] all nan after dim_avg_n_Wrap, replace_ieeenan solved the issue

xiaoming Hu yuanfangcan at hotmail.com
Fri Apr 23 21:43:14 MDT 2021


Thanks

Indeed!  The following code solved the issue:

    if(.not.isatt(wetland_CH4_emissions_ens,"_FillValue")) then
      wetland_CH4_emissions_ens at _FillValue = default_fillvalue(typeof(wetland_CH4_emissions_ens))
    end if
;    replace_ieeenan (wetland_CH4_emissions_ens, wetland_CH4_emissions_ens at _FillValue, 0); lead to values over Ocean
    replace_ieeenan (wetland_CH4_emissions_ens, 0.0, 0)

Xiao-Ming Hu

________________________________
From: Adam Phillips <asphilli at ucar.edu>
Sent: Friday, April 23, 2021 1:05 PM
To: xiaoming Hu <yuanfangcan at hotmail.com>
Cc: Dennis Shea <shea at ucar.edu>; ncl-talk at ucar.edu <ncl-talk at ucar.edu>; Xiaoming Hu <xhu at ou.edu>
Subject: Re: [ncl-talk] all nan after dim_avg_n_Wrap

Hi Xiaoming,
NaN's are likely present in your wetland_CH4_emissions_ens array. You can use isnan_ieee/replace_ieeenan to fix that:
https://www.ncl.ucar.edu/Document/Functions/Built-in/isnan_ieee.shtml
Adam


On Fri, Apr 23, 2021 at 11:01 AM xiaoming Hu via ncl-talk <ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>> wrote:
4-dimension array summary is actually before applying dim_avg_n_Wrap

See more detailed diagnose, code:
  printVarSummary(wetland_CH4_emissions_ens)
  printMinMax(wetland_CH4_emissions_ens,0)
  wetland_CH4_emissions = dim_avg_n_Wrap(wetland_CH4_emissions_ens,0) ; [model | 18] x [time | 228] x [lat | 360] x [lon | 720]
  print("got ensembe everage")
      printMinMax(wetland_CH4_emissions,0)
  printVarSummary(wetland_CH4_emissions)

Output:
Variable: wetland_CH4_emissions_ens
Type: double
Total Size: 8510054400 bytes
            1063756800 values
Number of Dimensions: 4
Dimensions and sizes: [model | 18] x [time | 228] x [lat | 360] x [lon | 720]
Coordinates:
            model: [1913..3934]
            time: [   1.. 228]
Number Of Attributes: 1
  units : mg CH4 m-2 day-1
(0) min=-0   max=535.915259495705
(0) got ensembe everage
(0) min=-nan   max=-nan

Variable: wetland_CH4_emissions
Type: double
Total Size: 472780800 bytes
            59097600 values
Number of Dimensions: 3
Dimensions and sizes: [time | 228] x [lat | 360] x [lon | 720]
Coordinates:
            time: [   1.. 228]
Number Of Attributes: 2
  units : mg CH4 m-2 day-1
  average_op_ncl : dim_avg_n over dimension(s): model


________________________________
From: Dennis Shea <shea at ucar.edu<mailto:shea at ucar.edu>>
Sent: Friday, April 23, 2021 11:53 AM
To: xiaoming Hu <yuanfangcan at hotmail.com<mailto:yuanfangcan at hotmail.com>>
Cc: ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu> <ncl-talk at ucar.edu<mailto:ncl-talk at ucar.edu>>
Subject: Re: [ncl-talk] all nan after dim_avg_n_Wrap

The source array is:  [model | 18] x [time | 228] x [lat | 360] x [lon | 720]

The output array from:

wetland_CH4_emissions = dim_avg_n_Wrap(wetland_CH4_emissions_ens,0)

should be 3-dimensions: [time | 228] x [lat | 360] x [lon | 720]

You show 4-dimensions.


On Fri, Apr 23, 2021 at 10:07 AM xiaoming Hu via ncl-talk <ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>> wrote:
I have used dim_avg_n_Wrap for a long time and never had issues. But today it led to all nan, any idea? Thanks,
xiaoming

See my code:
  printVarSummary(wetland_CH4_emissions_ens)
  printMinMax(wetland_CH4_emissions_ens,0)
  wetland_CH4_emissions = dim_avg_n_Wrap(wetland_CH4_emissions_ens,0) ; [model | 18] x [time | 228] x [lat | 360] x [lon | 720]
  print("got ensembe everage")
      printMinMax(wetland_CH4_emissions,0)

and output:
Variable: wetland_CH4_emissions_ens
Type: double
Total Size: 8510054400 bytes
            1063756800 values
Number of Dimensions: 4
Dimensions and sizes: [model | 18] x [time | 228] x [lat | 360] x [lon | 720]
Coordinates:
            model: [1913..3934]
            time: [   1.. 228]
Number Of Attributes: 1
  units : mg CH4 m-2 day-1
(0) min=-0   max=535.915259495705
(0) got ensembe everage
(0) min=-nan   max=-nan


_______________________________________________
ncl-talk mailing list
ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>
List instructions, subscriber options, unsubscribe:
https://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
ncl-talk at mailman.ucar.edu<mailto:ncl-talk at mailman.ucar.edu>
List instructions, subscriber options, unsubscribe:
https://mailman.ucar.edu/mailman/listinfo/ncl-talk


--
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/<http://www.cgd.ucar.edu/staff/asphilli/>   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210424/3d3d5d9b/attachment.html>


More information about the ncl-talk mailing list