This guest post is written by Hannah Aizenman, one of our Google Summer of Code students, who is working on a web-based visualisation tool for reconstructions of late Holocene temperatures, for the Common Climate Project (CCP).
Since my last blog post my project has progressed enough that the code can actually be used to make graphs of some sort, mostly plots of GISTEMP anomalies. The code is separated into two distinct parts: code that handles the data and code that handles the graphs.
The data part is pretty straightforward; give the code the path to the data and it’ll try to unpack the data and pull all the metadata out of the file. This is achieved as follows:
file_path = '../data/fields/gistemp_sat_anom_2.5deg.nc' data_obj = unpack.CCPDataFromNetCDF(file_path, field = 'field')
Then the data can be pulled out of the file using:
im = data_obj.get_all_data()
Note: there is also a get_data() function for doing online calculations over multiple files.
Once the data is pulled out of the file, it’s up to the user to run it through whatever algorithm he or she chooses to and spit out data to be graphed. For this post, I just took the mean of all the observations:
missing = data_obj.missing_value mask = [im == missing] im_masked = np.ma.masked_array(im, mask) masked = im_masked.std(0)
Next it’s time to set up the graph, starting off with setting the attributes and creating the object:
graph_attrs = dict( projection = 'moll', title = 'gistemp_sat_anom_2.5deg', cmap = 'gist_heat_r', xlabel = 'longitude', ylabel = 'latitude', cblabel = 'std dev of temp anomalies') graph_obj = spatial.SpatialGraph(data_obj, **graph_attrs)
And to finish off and create the image:
This code is also available for download at: https://code.google.com/p/ccp-viz-toolkit/source/browse/scripts/demo_gis.py