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

Running "First guess test" using Python #26

Open
meteorolog90 opened this issue Aug 16, 2023 · 1 comment
Open

Running "First guess test" using Python #26

meteorolog90 opened this issue Aug 16, 2023 · 1 comment

Comments

@meteorolog90
Copy link

Greetings. My goal is to set up a first guess test using Python. The Wiki only has R-code examples, so I converted them to Python syntax. My setup looks like this:

N = len(lats)

obs_to_check = np.array([1])
obs_to_check = np.repeat(obs_to_check, N, axis = 0)

background_values = np.array([0])
background_values = np.repeat(background_values, N, axis = 0)

background_uncertainties = np.array([1])
background_uncertainties = np.repeat(background_uncertainties, N, axis = 0)


background_elab_type = "MedianOuterCircle"
T = 'True'

num_min_outer = 3
num_max_outer = 10
inner_radius = 20000
outer_radius = 50000
num_iterations = 10
num_min_prof = 0
min_elev_diff = 100
min_horizontal_scale = 250 
max_horizontal_scale = 100000
kth_closest_obs_horizontal_scale = 2
tpos = np.repeat(obs_to_check, N, axis = 0) * 5
tneg = np.repeat(obs_to_check, N, axis = 0) * 5
values_mina = [num-20 for num in temp]
values_maxa = [num+20 for num in temp]
values_minv = [num-1 for num in temp]
values_maxv = [num+1 for num in temp]
debug = T
basic = T

res = titanlib.fgt( points, temp, obs_to_check,
 
    background_values, 
    background_uncertainties, 
    background_elab_type, 
    num_min_outer, 
    num_max_outer, 
    inner_radius, 
    outer_radius, 
    num_iterations, 
    num_min_prof, 
    min_elev_diff, 
    values_mina, 
    values_maxa, 
    values_minv, 
    values_maxv, 
    tpos, 
    tneg, 
    debug, 
    basic
    
)

Here is the error message I get:

File "first_quess_test.py", line 152, in <module> basic File "/users/nwp999/bin/pynwp/lib64/python3.6/site-packages/titanlib.py", line 892, in fgt return _titanlib.fgt(points, values, obs_to_check, background_values, background_uncertainties, background_elab_type, num_min_outer , num_max_outer, inner_radius, outer_radius, num_iterations, num_min_prof, min_elev_diff, value_mina, value_maxa, value_minv, value_max v, tpos, tneg, debug, basic) TypeError: in method 'fgt', argument 6 of type 'titanlib::BackgroundType'

Is it possible to run this test using Python ?

@trygveasp
Copy link
Collaborator

The background (background_elab_type) must be a background object and not a string.

I have not implemented exactly this test in pysurfex, but there is another first guess using the range_check test from titan where I have interpolated observations and background using gridpp:

https://github.com/metno/pysurfex/blob/master/pysurfex/titan.py#L277

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