14 | | * `var`: Variable code. Argument values currently accepted are `tas`, `tasmin`, `tasmax`, `pr` or `mslp`, as internally defined in the vocabulary for System4 following the nomenclature displayed in the table below. However, note that new variables and datasets will be progressively included. Note that depending on the time step of the variable the units might be referred to different time aggregations. For instance, currently `mslp` is 6-hourly, and thus the 6-hourly mean value is returned for each time step. Similarly, 24-h accumulated values are returned for `pr`, and so on. Note that the ''instantaneous'' and ''aggregated'' fields in table below refer to the potential time step values that the variables may take, which does not mean that the resolution provided by the System4 model is necessarily that. |
| 14 | * `var`: Variable code. Argument values currently accepted are `tas`, `tasmin`, `tasmax`, `pr` or `mslp`, as internally defined in the vocabulary for System4 following the nomenclature displayed in the table below. However, note that new variables and datasets will be progressively included and that depending on the time step of the variable the units might be referred to different time aggregations. For instance, currently `mslp` is 6-hourly, and thus the 6-hourly mean value is returned for each time step. Similarly, 24-h accumulated values are returned for `pr`, and so on. Note that the ''instantaneous'' and ''aggregated'' fields in table below refer to the potential time step values that the variables may take, which does not mean that the resolution provided by the System4 model is necessarily that. |
51 | | >>> year=[1990,1991,1992,1993,1994,1995,1996,1997,1998,1999] |
52 | | >>> members=[0] |
53 | | >>> dataset="http://%s:%s@www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml" %(username,password) |
| 50 | >>> year = [1990,1991,1992,1993,1994,1995,1996,1997,1998,1999] |
| 51 | >>> members = [0] |
| 52 | >>> username = "myUsername" |
| 53 | >>> password = "myPassword" |
| 54 | >>> dataset = "http://%s:%s@www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml" %(username,password) |
| 67 | |
| 68 | Another common task is the representation of time series for selected point locations/grid cells. In this example, we will display time series of the requested dataset at the four grid points coincident with the cities represented in the map. To this aim, we will create a function that search the data of the nearest grid points to the specified locations. |
| 69 | |
| 70 | {{{ |
| 71 | >>> def plot_serie_cities(cities_latlon,cities_name,ud): |
| 72 | ... pcolors = { |
| 73 | ... "0":"blue", |
| 74 | ... "1":"green", |
| 75 | ... "2":"red", |
| 76 | ... "3":"purple", |
| 77 | ... "4":"cyan", |
| 78 | ... "5":"yellow", |
| 79 | ... "6":"magenta", |
| 80 | ... "7":"pink", |
| 81 | ... "8":"orange", |
| 82 | ... "9":"brown", |
| 83 | ... "10":"grey", |
| 84 | ... } |
| 85 | ... fig=plt.figure() |
| 86 | ... ax = fig.add_subplot(111) |
| 87 | ... x=np.arange(len(ud.times)) |
| 88 | ... xticks_mask = [d.month in season and d.day == 1 for d in ud.times] |
| 89 | ... xticks = x[np.array(xticks_mask)] |
| 90 | ... ax.set_xticks(xticks) |
| 91 | ... ticklabels=[t.strftime("%Y-%m") for t in ud.times[np.array(xticks_mask)]] |
| 92 | ... ax.set_xticklabels(ticklabels) |
| 93 | ... plt.xticks(rotation=25) |
| 94 | ... plt.ylabel("%s (%s)" %(var,ud.units)) |
| 95 | ... lat = cities_latlon[:,0] |
| 96 | ... lon = cities_latlon[:,1] |
| 97 | ... for i in np.arange(len(cities_name)): |
| 98 | ... city_position=(((ud.LatLonCoords[0,:]-lon[i])**2)+((ud.LatLonCoords[1,:]-lat[i])**2)).argmin() |
| 99 | ... city = ud.data[:,city_position] |
| 100 | ... c=("%("+str(i)+")s") % pcolors |
| 101 | ... plt.plot(city,color=c, label=cities_name[i]) |
| 102 | ... plt.legend(loc="lower left",prop={'size':'small'}) |
| 103 | ... plt.savefig("map_serie_all_cities.png") |
| 104 | }}} |
| 105 | |
| 106 | Once we hace the function defined, we use it to plot the graph. |
| 107 | {{{ |
| 108 | >>> plot_serie_cities(cities_latlon,cities_name,ud) |
| 109 | }}} |
| 110 | [[Image(map_serie_all_cities.png,center)]] |