Ignore:
Timestamp:
06/07/17 10:50:54 (8 years ago)
Author:
Eric.Larour
Message:

CHG: merged branch back to trunk-jpl 21754.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-larour-NatGeoScience2016/src/py3/mech/steadystateiceshelftemp.py

    r19895 r21759  
    1 import numpy as npy
     1import numpy as np
    22
    33def steadystateiceshelftemp(md,surfacetemp,basaltemp):
     
    4242        temperature=(Ts+Tb)/2  # where wi~=0
    4343       
    44         pos=npy.nonzero(abs(wi)>=1e-4) # to avoid division by zero
     44        pos=np.nonzero(abs(wi)>=1e-4) # to avoid division by zero
    4545
    46         npy.seterr(over='raise',divide='raise') # raise errors if floating point exceptions are encountered in following calculation
     46        np.seterr(over='raise',divide='raise') # raise errors if floating point exceptions are encountered in following calculation
    4747        #calculate depth-averaged temperature (in Celsius)
    4848        try:
    49                 temperature[pos]=-( (Tb[pos]-Ts[pos])*ki/wi[pos] + Hi[pos]*Tb[pos] - (Hi[pos]*Ts[pos] + (Tb[pos]-Ts[pos])*ki/wi[pos])*npy.exp(Hi[pos]*wi[pos]/ki) )/( Hi[pos]*(npy.exp(Hi[pos]*wi[pos]/ki)-1))
     49                temperature[pos]=-( (Tb[pos]-Ts[pos])*ki/wi[pos] + Hi[pos]*Tb[pos] - (Hi[pos]*Ts[pos] + (Tb[pos]-Ts[pos])*ki/wi[pos])*np.exp(Hi[pos]*wi[pos]/ki) )/( Hi[pos]*(np.exp(Hi[pos]*wi[pos]/ki)-1))
    5050        except FloatingPointError:
    5151                print('steadystateiceshelf warning: overflow encountered in multipy/divide/exp, trying another formulation.')
    52                 temperature[pos]=-( ((Tb[pos]-Ts[pos])*ki/wi[pos] + Hi[pos]*Tb[pos])/npy.exp(Hi[pos]*wi[pos]/ki) - Hi[pos]*Ts[pos] + (Tb[pos]-Ts[pos])*ki/wi[pos])/( Hi[pos]*(1-npy.exp(-Hi[pos]*wi[pos]/ki)))
     52                temperature[pos]=-( ((Tb[pos]-Ts[pos])*ki/wi[pos] + Hi[pos]*Tb[pos])/np.exp(Hi[pos]*wi[pos]/ki) - Hi[pos]*Ts[pos] + (Tb[pos]-Ts[pos])*ki/wi[pos])/( Hi[pos]*(1-np.exp(-Hi[pos]*wi[pos]/ki)))
    5353       
    5454        #temperature should not be less than surface temp
    55         pos=npy.nonzero(temperature<Ts)
     55        pos=np.nonzero(temperature<Ts)
    5656        temperature[pos]=Ts[pos]
    5757       
    5858        # NaN where melt rates are too high (infinity/infinity in exponential)
    59         pos=npy.nonzero(npy.isnan(temperature))
     59        pos=np.nonzero(np.isnan(temperature))
    6060        temperature[pos]=Ts[pos]
    6161       
Note: See TracChangeset for help on using the changeset viewer.