Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some error happen #32

Open
pikaqiu2002 opened this issue Aug 14, 2024 · 4 comments
Open

some error happen #32

pikaqiu2002 opened this issue Aug 14, 2024 · 4 comments

Comments

@pikaqiu2002
Copy link

pikaqiu2002 commented Aug 14, 2024

Good afternoon all,

When I run the code, the code cannot run after changing the ice_type from ‘firstyear’ to ‘multiyear’. I don't know what went wrong. Is there any parameter that is not restricted? Can someone help me?

Thank you very much,

John

@pikaqiu2002
Copy link
Author

The error reported is as follows
‘For mass simulations, exceptions may be annoying, to avoid raising exception and return NaN as a result instead is
obtained by setting the option error_handling='nan'.

Note:: setting an option in DORT is obtained with make_model(..., "dort", rtsolver_options=dict(error_handling='nan')).’

@pikaqiu2002
Copy link
Author

I may have placed the code in the wrong way, below is the code.

# import libraries
import numpy as np

# import smrt and related functions
from smrt import make_ice_column, make_snowpack, make_model, sensor
from smrt import PSU # g/kg -> kg/kg conversion
from smrt.atmosphere.simple_isotropic_atmosphere import SimpleIsotropicAtmosphere
from smrt.core.interface import make_interface # import lib for roughness

# ice inputs
l           = 2                             # number ice layers
thickness   = np.array([.5,.5])             # ice thickness in m
radius      = np.array([.0001,.0001])       # particle radius
stickiness  = np.array([0.3, 0.3])          # 'tau' 
temperature = np.array([260, 265])          # ice temperature in K
salinity    = np.array([5.1, 5.4])*PSU      # ice salinity profile in kg/kg
density     = np.array([0.924,0.924])       # ice density profile in kg/m^3
mean_square_slope = 0.1                       # MSS (unitless) mean_square_slope = 2*s**2/l**2

# atmosphere
atmos = SimpleIsotropicAtmosphere(10., 3., 0.90)

# create a first-year sea ice column:
################################################# CHANGE HERE FROM 'FIRSTYEAR' TO 'MULTIYEAR'
ice_type = 'multiyear' # first-year or multi-year sea ice
#################################################

rough_interface = make_interface("geometrical_optics",\
                                 mean_square_slope=mean_square_slope)

ice_column = make_ice_column(ice_type              = ice_type,
                             thickness             = thickness, # meters
                             temperature           = temperature,
                             microstructure_model  = "sticky_hard_spheres",
                             brine_inclusion_shape = "spheres", 
                             salinity              = salinity, 
                             brine_volume_fraction = .02,
                             radius                = radius,
                             stickiness            = stickiness,
                             density               = density,
                             add_water_substrate   = "ocean" #see comment below
                            )
ice_column.interfaces[0]=rough_interface
#ice_column.interfaces[1]=rough_interface

# snow inputs:
l_s           = 2                            # number of layers
thickness_s   = np.array([.12,.12])          # thickness per layer
density_s     = np.array([216,100])          # density profile in kg/m^3
radius_s      = np.array([.0004, .00025])    # particle radius
stickiness_s  = np.array([0.20, 0.20])       # 'tau' (stickiness)
temperature_s = np.array([253, 252])         # temperature

# create the snowpack
snowpack = make_snowpack(thickness            = thickness_s,
                         microstructure_model = "sticky_hard_spheres",
                         density              = density_s,
                         temperature          = temperature_s,
                         radius               = radius_s,
                         stickiness           = stickiness_s)

snowpack.atmosphere = atmos# from test

#add snowpack on top of ice column:
medium = snowpack + ice_column

# create geometric and EM parameters
theta        = 40          # Earth incidence angle
freq         = 6E9     # range of frequencies  (Hz)
#sensor=sensor.passive(freq, theta)
sensor=sensor.active(freq, theta)
# make model
n_max_stream = 128           # TB calcis more accurate if # of streams increased
                            # (currently: default = 32); 
                            # needs to be increased when using > 1 snow layer 
m = make_model("iba", "dort", rtsolver_options ={"n_max_stream": n_max_stream}
               )

# run the model for bare sea ice:
#res1 = m.run(sensor, ice_column)
# run the model for snow-covered sea ice:
res2 = m.run(sensor, medium)

# print TBs at horizontal and vertical polarization:
#print(res1.TbH(), res1.TbV())
#print(res2.TbH(), res2.TbV())
print(res2.sigmaVV_dB(), res2.sigmaHH_dB())

@ghislainp
Copy link
Member

The ice density values are not in the right unit. They must be in kg/m3.
That could explain that you get NaN somewhere, as a few variables are deduced from the density in a non-linear way for saline ice (and it is different for first and multi year ice).

@pikaqiu2002
Copy link
Author

The ice density values are not in the right unit. They must be in kg/m3. That could explain that you get NaN somewhere, as a few variables are deduced from the density in a non-linear way for saline ice (and it is different for first and multi year ice).

Thank you!!The problem has been solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants