You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 5
Next »
How to loop over all the fields in my fieldset?
Step-by-step guide
Create a loop over the number of fields, and setting the parameter grib_field_position to the position of the field in your fieldset ( starting from 1)
from Magics.macro import *
#Setting output
output = output(
output_formats = ['ps'],
output_name = 'precip',
output_name_first_page_number = 'off')
#Setting the coastlines
background = mcoast(
map_coastline_land_shade = 'on',
map_coastline_land_shade_colour = 'cream')
#Defining the contour
contour = mcont(
)
#actions will contains the list of actions to pass to Magics
actions = []
# n is the number of filds in the fieldset
for i in range(1, n) :
#Setting data
grib = mgrib(grib_field_position = i,
grib_input_file_name = "path/data.grib")
actions.append(background)
actions.append(grib)
actions.append(contour)
# Add an page() action to create a new page
actions.append(page())
#Plotting
plot(output, actions)
Related articles
There is no content with the specified labels