We show the practical use of the tools though a set of simple examples.
2.1 Hello NEX-GDDP-CMIP6
We provide a simple jupyter notebook for loading wiht th OpenVisus library one timestep of one variable and display it though the matplotlib library and also sabing it to a file. In a few lines of Python code a user can plot an image of the NEX-GDDP-CMIP6 as in Figure Figure 2.2.
Figure 2.1: Simple plot of the NEX-GDDP-CMIP6 data as a numpy array. Note how the axes of the plot are labeled with the indices of the array and not with longitude and latitude corrdinates of the data.
2.1.1.1 Create name of teh datset in variable dataset_name, open it as db and print its information.
# Set climate variablesmodel ="ACCESS-CM2"variable ="huss"year =2020# 2015 is the year whne the data switches from historical to simulatedscenario ="ssp585"field =f"{variable}_day_{model}_{scenario}_r1i1p1f1_gn"# Open remote dataset to variable dbdb = ov.LoadDataset(f"http://atlantis.sci.utah.edu/mod_visus?dataset=nex-gddp-cmip6&cached=arco")print("Url:", db.getUrl())
2.1.1.2 Convert the date of desride data into anm index timestep and load the data into a numpy array data to print its information.
# Set timestep to day corresponds to July 21. See https://nsidc.org/data/user-resources/help-center/day-year-doy-calendarday_of_the_year =202timestep =year*365+ day_of_the_year# load the data into numpy array and print array infomrationdata=db.read(field=field,time=timestep) #load anta in a numpy arraynp.info(data) # print array information
2.1.2 Plot the data adn save it to an PNG image using the matplotlib library.
import matplotlib.pyplot as pltmy_cmap ='gist_rainbow'plt.subplots(figsize=(18,9))plt.imshow(data, cmap=my_cmap,origin='lower') # matplotlib puts the origin on the top left instead of bottom leftplt.savefig( "NEX-GDDP-CMIP6_ACCESS-CM2_tas_ssp585_2020_day202.png")plt.show()
Figure 2.2: Simple plot of the NEX-GDDP-CMIP6 data as a numpy array. Note how the axes of the plot are labeled with the indices of the array and not with longitude and latitude corrdinates of the data.