Package: cgeniepy
cgeniepyis an Python interface to the output ofcGENIE Earth System Model. It is an alternative to the existingMATLAB libraries. It aims to facilitate the post-simulation analysis, including reading and analysing the model output, and observational data.⚠cgeniepyis still in alpha phase and under active changes.InstallationInstall fromtestpypi.python3-mpipinstall-ihttps://test.pypi.org/simple/cgeniepy==0.10.1Install from GitHub:python3-mpipinstallgit+https://github.com/ruiying-ocean/cgeniepy.git@masterQuickstart0. initialise a model instancefromcgeniepy.modelimportGenieModel## single modelmodel=GenieModel('path_a')## model ensemblemulti_dirs=['/path_a/','/path_b/']model=GenieModel(path_to_model_output)1. Read datanetCDF (*.nc)time series (*.res)## time slice datamodel.get_var("XXXXX").array## timeseries datamodel.get_ts("biogem_series_ocn_temp.res")2. Data analysisData subsetting and statisticsModel performanceUnit-changing operation (e.g., rate to magnitude)## get zonal average SST of the last model yearzonal_sst=model.get_var("ocn_sur_temp").isel(time=-1).mean(dim='lat')## North Pacific SSTnpac_sst=model.get_var("ocn_sur_temp").select_basin(47).isel(time=-1)3. Visualisation1D line (time series, zonal average)2D map (including various projections like polar map)2D cross section3D (facet)Add a layer of observational data## simply call `plot` after accessing the data## mapmodel.get_var("ocn_sur_temp").isel(time=-1).plot()4. OthersECOGEM shortcutsfromcgeniepy.ecologyimportEcoModelmodel=EcoModel(path_to_model_path)## get all phytoplankton carbon biomass and plot as mapmodel.get_pft("Phyto","Biomass","C").isel(time=-1).plot()GalleryA global biomass map of modelled picophytoplankton (0.6 μm)## initialise a EcoModel instance before running thismodel.get_pft(1,"Biomass","C").isel(time=-1).plot(contour=True)A global distribution of basin-level nutrient (PO4)## initialise a GenieModel instance before running thisimportmatplotlib.pyplotaspltfig,axs=plt.subplots(nrows=1,ncols=3,figsize=(15,3),tight_layout=True)basins=['Atlantic','Pacific','Indian']foriinrange(3):basin_data=model.get_var('ocn_PO4').isel(time=-1).mask_basin(base='worjh2',basin=basins[i],subbasin='')basin_data.array.values=basin_data.array.values*1E6basin_data.mean(dim='lon').plot(ax=axs[i],contour=True)axs[i].title.set_text(basins[i])Additional Colour Palettesimportnumpyasnpimportmatplotlib.pyplotaspltfromcgeniepy.plotimportcommunity_palette,avail_palettedefplot_colormaps(cmaps):ncols=4nrows=int(np.ceil(len(cmaps)/ncols))fig,axes=plt.subplots(nrows,ncols,figsize=(15,nrows))fori,cmap_nameinenumerate(cmaps):row=i//ncolscol=i%ncolsax=axes[row,col]ifnrows>1elseaxes[col]# Create a gradient image using the colormapgradient=np.linspace(0,1,256).reshape(1,-1)ax.imshow(gradient,aspect='auto',cmap=community_palette(cmap_name))ax.set_title(cmap_name,fontsize=14,fontweight='bold')ax.axis('off')## remove the unused axesforiinrange(len(cmaps),ncols*nrows):row=i//ncolscol=i%ncolsfig.delaxes(axes[row,col])plt.tight_layout()# List of colormaps from cgeniepycmaps_list=avail_palette()plot_colormaps(cmaps_list)Project Roadmap 🚩Publish the first stable versionplot.py 3D facet subplotsShow one colorbar in transect plotignore NAs when searching griduse lat/lon/zt from GENIE outputDocumentation Webistefigsize influences colorbar lengthcreate a simple logoallow reading an ensemble of models (netcdf & timeseries)formatting the ugly unit stringobservation.py including plot scatterAdd global inventory functionKiller Features[X] Model-data comparison
[X] Model ensemble support
[X] Search the nearestvalidgrid pointCitation@software{cgeniepy,
  author ={Rui Ying},
  title ={A Python interface to analyse and visualise cGENIE model output},
  url ={https://github.com/ruiying-ocean/cgeniepy/},
  version ={0.10.1},
  date ={2024-02-17},}LogoLogo is designed by me using freerighteousfont.AlternativeAlex Phol'sgenie_basicdiagsRaise a bugPlease use GitHub's Issues to raise a bug. This makes the issues traceable so that future users having the same problem can find the answer in the public domain.