[ncl-talk] regridding with int2p_n_Wrap

Dennis Shea shea at ucar.edu
Thu May 12 09:21:12 MDT 2016


re: "int2n_p itself doesn't have the constraint?"

No. it just performs 'unconstrained' extrapolation. There are numerous
cases where negative values are appropriate.

===
re: "if we want to avoid the negatives values, should we manually set some
constraints or what is the best way to do it?"

One brute force approach .... after the extrapolation

http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml

   xLowLimit = 0.0        ; user set value appropriate for variable
   x = where(x.lt.xLowLimit, xLowLimit, x)

===
re: just wondering how do you know the max = 2.0197e-13 is a numerical
issue?

I don't know .... I was speculating. Based on your analysis, it may well be
appropriate.

Good Luck

On Thu, May 12, 2016 at 8:02 AM, Huanxin(Jessie) Zhang <huanxinz at mtu.edu>
wrote:

> Hi Dennis,
>
> Thank you so much for your reply and I really appreciate it!
>
> [2] so the routine int2n_p itself doesn't have the constraint? if we want
> to avoid the negatives values, should we manually set some constraints or
> what is the best way to do it?
>
> [3]============
> printMinMax(OH_in,0)                            ;      "
> Chemically produced OH (kg/m3) : min=0   max=2.0197e-13  <********
>
> ****The latter number is numerically 0.0  ... No range!
>       You are essentially using a constant field ****
>
> just wondering how do you know the max = 2.0197e-13 is a numerical issue?
> I am little bit confused. Here It is the OH concentration in kg/m3. I just
> did a quick conversion, typical OH concentration in the atmosphere is about
> 10e5 molecules/cm3, to covert it to kg/m3,  it is OH_new=
> (10e5/(6.022e23/17e-3)) * 1e6, then the magnitude of the new concentration
> in kg/m3 is roughly about 1e-14 kg/m3, therefore, I think the max values is
> not a numerical issue?
>
> Thank you so much for your time!
> Jessie
>
> On Wed, May 11, 2016 at 7:05 PM, Dennis Shea <shea at ucar.edu> wrote:
>
>> [1] re: "or if there are ways to conserve the mass"
>>
>> Yes, read the ESMF documentation. Use "conserve" method ... not bilinear
>>
>> "conserve" - this method will typically have a larger interpolation error
>> than the previous two methods, but will do a much better job of preserving
>> the value of the integral of data between the source and destination grid.
>>
>> [2] Before proceeding the general rule is that  extrapolation is
>> dangerous: frequently, VERY dangerous'
>>
>> The extrapolation used within int2p_n is simple linear extrapolation.
>>
>> The following is trivial example
>>
>> Impose a constraint: Let's say the 'val' quantity should be always >= 0.
>>
>>       val(3)   val at level(3)    100
>>       val(1)   val at level(1)      0
>>
>>       val(2)= (val(1) + val(3))/2   ; toy interploation   val(2) = 50
>>
>>        VAL(1) = 2*val(2)-val(3)    ; here, VAL(1)=val(1)=0
>>        VAL(0) = 2*val(1)-val(2)    ; extrapolate ......  VAL(0) = -50
>>
>> ==================================================---
>> [3]
>>
>> Did you look at the numbers on your file? Basically all 0s
>>
>> [SNIP]
>>     ;######################
>>     ; Read variable
>>     ;######################
>>
>>         OH_in   = f->OH
>>
>> printVarSummary(OH_in)
>>
>> ================>  source variable
>> Variable: OH_in
>> Type: float
>> Total Size: 45287424 bytes
>>             11321856 values
>> Number of Dimensions: 4
>> Dimensions and sizes:   [time | 12] x [lev | 72] x [lat | 91] x [lon |
>> 144]
>>                                                            ^^^^^^^^
>> Number Of Attributes: 7
>>   add_offset :   0
>>   scale_factor :         1                <=== no scaling
>>
>> ============
>> printMinMax(OH_in,0)                            ;      "
>> Chemically produced OH (kg/m3) : min=0   max=2.0197e-13  <********
>>
>> ****The latter number is numerically 0.0  ... No range!
>>       You are essentially using a constant field ****
>> =================
>>     ;######################
>>     ; Regrid Horizontally
>>     ;######################
>>
>>         OH_mid  = ESMF_regrid_with_weights(OH_in,wgtFileName,Opt)
>> printVarSummary(OH_mid)
>> printMinMax(OH_mid,0)
>>
>> ---
>>   remap :       remapped via ESMF_regrid_with_weights: Bilinear remapping
>> (0)     Chemically produced OH (kg/m3) : min=0   max=1.45516e-13
>>
>> No negative sign but numerically all 0
>> ----
>>     ;########################
>>     ; Interpolate Vertically
>>     ;########################
>>     ; Linear interpolation, extrapolate near surface  <=========
>>     OH_out               = int2p_n_Wrap(pMid, OH_mid, pOut, -1,1)
>> printVarSummary(OH_out)
>> printMinMax(OH_out,0)
>> [SNIP]
>>
>> Variable: OH_out
>>
>> Number of Dimensions: 4
>> Dimensions and sizes:   [time | 12] x [lev | 40] x [lat | 90] x [lon |
>> 144]
>>                                                           ^^^^^^^^^
>> Coordinates:
>>             time: [ 0..8016]
>>             lat: [ -90..  90]
>>             lon: [-178.75..178.75]
>>
>> (0)     Chemically produced OH (kg/m3) : min=-1.18855e-18
>> max=1.39631e-13
>>
>> That -1.188e-18 is basically a numerical issue ... it is 0
>>
>>
>>
>>
>> On Tue, May 10, 2016 at 8:38 PM, Huanxin(Jessie) Zhang <huanxinz at mtu.edu>
>> wrote:
>>
>>> Hi, All
>>>
>>> I have tried to do some vertical regridding work with NCL function
>>> int2p_n_wrap. I am trying to regrid the OH concentration (in kg/m3)  from
>>> MERRA 2x2.5 grid (144x91x72) to GISS ModelE F40 (144x90x40). However, I
>>> have found some negative values in the regridded grid when I set linlog =
>>> -1. The negative values only happen on the first two levels near the
>>> surface and the rest of the levels seem to be fine.  I think it is mainly
>>> because of the extrapolation near the surface. If I set linlog = 1, there
>>> will be some missing values in the first several levels near the surface
>>> then. I also tried to regrid other units such as mixing ratio and the same
>>> thing happens. I am not sure if it is because that the units can not just
>>> be interpolated or if there are ways to conserve the mass? I just started
>>> to learn how to use NCL and I couldn't figure out how to solve this. If
>>> anyone has some comments on how to address this, I would really appreciate
>>> it!
>>>
>>> Attached is the NCL script used and I have uploaded the files needed to
>>> run the script to *ftp.cgd.ucar.edu/incoming
>>> <http://ftp.cgd.ucar.edu/incoming>.* These files are:
>>> OH_3Dglobal.geos5.72L.2x25.hemco.nc; pressure.MERRA.nc;
>>> pressure.GCAP_2000s.F40.nc.
>>>
>>> p.s. I am using NCL version 6.3.0 and the system I am on is linux
>>> RHEL6.6x86_64.
>>>
>>> Thank you so much for your time!
>>> Jessie
>>> --
>>> Huanxin (Jessie) Zhang
>>> PhD Candidate in Environmental Engineering-Atmospheric Chemistry Modeling
>>> Dept. of Geological and Mining Engr. & Sciences
>>> Michigan Technological University
>>> 1400 Townsend Drive, Houghton, MI, 49931
>>> Email: huanxinz at mtu.edu <huanxinz at mtu.edu>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
>
> --
> Huanxin (Jessie) Zhang
> PhD Candidate in Environmental Engineering-Atmospheric Chemistry Modeling
> Dept. of Geological and Mining Engr. & Sciences
> Michigan Technological University
> 1400 Townsend Drive, Houghton, MI, 49931
> Email: huanxinz at mtu.edu <huanxinz at mtu.edu>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160512/1c7a4a60/attachment.html 


More information about the ncl-talk mailing list