Skip to content

Commit

Permalink
Add new yml file for variable resolution projection
Browse files Browse the repository at this point in the history
To run the update_uid.py under linux I should add the option shell=True in Popen
  • Loading branch information
MO-marcomilan authored and wdeconinck committed Feb 4, 2022
1 parent 6b508f0 commit 30e5e3f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
33 changes: 33 additions & 0 deletions doc/example-grids/regional_variable_resolution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# (C) Crown copyright 2022, Met Office
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# regional projection using variable resolution

type : "regular_lonlat"
nx : 34
ny : 32
projection :
type: "variable_resolution"
var_ratio : 1.13
delta_low : 1.
delta_hi : 0.6511482758621128
x_reg_start : 351.386944827586319
x_reg_end : 366.363355172413776
y_reg_start : -5.008754172413662
y_reg_end : 8.665359620690706
startx : 348.13120344827576
endx : 369.6190965517242
starty : -8.264495551724226
endy : 11.92110100000127
north_pole : {0.0, 90.0})
rim_widthx : 4
rim_widthy : 4

check :
size : 1088
lonlat(first) : [348.13120344827576,-8.264495551724226]
lonlat(last) : [170,11.92110100000127]
bounding_box(n,w,s,e) : [-8.264495551724226,348.13120344827576,11.92110100000127,369.6190965517242]
uid : f164da5624c5335853cdb7d5754ebd1a

10 changes: 9 additions & 1 deletion doc/example-grids/update_uid.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def run_program_get_error(file):

from subprocess import Popen, PIPE

p = Popen(command, stdout=PIPE, stderr=PIPE)
#Marco Milan: add shell=True for run in linux
p = Popen(command, stdout=PIPE, stderr=PIPE, shell=True)
output, error = p.communicate()
if p.returncode != 0:
return str(error.strip(),'ascii')
Expand Down Expand Up @@ -55,14 +56,21 @@ def process_file( file, newfile ):


import sys
print(sys.argv)
program = sys.argv[1]

print( "Updating uids of grids with program [",program,"]")

import os

print('file: ', __file__)
directory = os.path.dirname(os.path.realpath(__file__))

print('directory:', directory)


for root, dirs, files in os.walk(directory):
print('root: ', root)
for file in files:
if file.endswith('.yml'):
file = root+"/"+file
Expand Down

0 comments on commit 30e5e3f

Please sign in to comment.