Hi all,
I am working with my own version of the u-al752 suite and would like to run JULES over a loop passing site as a variable in place of LBA_K34 in the code below:
{% import “numpy” as np %}
{%- for site in site_info %}
…
#SET MAIN & SPINUP SITE-SPECIFIC ENVIRONMENTS
[[jules_{{ site|lower }}_presc{{ PRESCRIBE_DATASETS_CONFIGURATION }}post]]
inherit = JULES_POST
{% set xa=np.load('/home/users/ndouglas/roses/u-cu756/bin/da_files/xaLBA_K34.npy’) %}
[[[environment]]]
…
ALPHA = {{ xa[0] }}
NEFF = {{ xa[1] }}
Does anybody have experience of this or know where I can look for notes on how to do it?
Many thanks,
Natalie
Hi Natalie
Can you replace LBA_K34 with {{ site }} in your site loop? Have you tried that already?
Patrick
Hi Patrick,
Yes I did and got this error:
Thanks,
Natalie
Hi Natalie:
Maybe you can concatenate the 3 substrings with the + operator? Does that make sense?
Patrick
Hi Patrick,
Yes, I tried: {% set xa=np.load(‘/home/users/ndouglas/roses/u-cu756/bin/da_files/xa_’+{{ site }}+‘.npy’) %} with error:
and {% set xa=np.load(‘/home/users/ndouglas/roses/u-cu756/bin/da_files/xa_’{{ site }}‘.npy’) %} with similar error:
The mind boggles.
Natalie
Hi Natalie:
Have you tried something like this?:
{% set filename=‘/home/users/ndouglas/roses/u-cu756/bin/da_files/xa_’+{{ site }}+‘.npy’
set xa=np.load(filename) %}
Patrick
Hi again Natalie
You might also need spaces before and after the + sign. And you can also write a short jinja program to test the syntax, which can be called from the command line of linux.
Patrick
Hi Patrick,
Thanks for all your help. Removing the curly braces seems to have worked:
{% set filename=‘/home/users/ndouglas/roses/u-cu756/bin/da_files/xa_’ + site + ‘.npy’ %}
{% set xa=np.load(filename) %}
Can you see any hidden problems that might arise from doing this?
Thanks,
Natalie
Hi Natalie
I am glad it works now.
I don’t see any hidden problems with that.
Did you also need to use spaces around the + signs?
Patrick
Hi Patrick,
It seems to work both with and without the spaces. Thanks!
Natalie