Skip to content

Instantly share code, notes, and snippets.

View atteggiani's full-sized avatar

Davide Marchegiani atteggiani

  • ACCESS-NRI
  • Canberra, Australia
  • 02:03 (UTC +11:00)
View GitHub Profile
@atteggiani
atteggiani / make_nitrogen_deposition_ancil.py
Last active November 30, 2023 08:33
Example of how to create the Nitrogen deposition ancillary file for ACCESS-ESM1.5 from a set of netCDF source files.
#!/usr/bin/env python3
"""
Create the ACCESS-ESM1.5 ancillary file needed for nitrogen deposition in UKESM1 for the CMIP6 SSP370 scenarioMIP
00447 0 NITROGEN DEPOSITION (kgN/m2/s) (ACCESS-CM2)
or
00884 0 NITROGEN DEPOSITION (gN/m2/d) (ACCESS-ESM1.5)
"""
import os
import ants
from ants.fileformats.ancil import _cubes_to_ancilfile, _mule_set_lbuser2
@atteggiani
atteggiani / make_monthly_tseries_ancil.py
Last active October 26, 2023 03:49
Example of how to make a monthly timeseries UM ancillary (input) file from a netCDF file, for an ACCESS-ESM1.5 or ACCESS-CM2 simulation (Example using a CO2 Emission ancillary file)
#!/usr/bin/env python3
import mule
import xarray as xr
rootDir = '/g/data/tm70/dm5220/ancil/tilo'
ancilFilename = f'{rootDir}/orig_co2'
netcdfFilename = f'{rootDir}/co2_new.nc'
start_yr = 201
end_yr = 300
@atteggiani
atteggiani / make_monthly_repeated_year_forcing_ancil.py
Last active October 23, 2023 06:13
Example of how to make a monthly repeated year forcing UM ancillary (input) file from a netCDF file, for an ACCESS-ESM1.5 or ACCESS-CM2 simulation (Example using a CO2 Emission ancillary file)
#!/usr/bin/env python3
# READ FILES
import mule
import xarray as xr
rootDir = '/scratch/public/dm5220/tilo'
ancilFilename = f'{rootDir}/orig_co2'
BMDI = -2.0**30 # (-1073741824.0) Value used in the UM Fieldsfile to indicate NaN