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).To know the number of fields in your grib files, you can use the function grib_count of the grib_api package. |
Add the steps involved:
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) |
To know the number of fields in your grib files, you can use the tool grib_count of the ecCodes package. |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.