Difference between revisions of "UKCA Chemistry and Aerosol vn10.4 Tutorial 5"

From UKCA
Line 15: Line 15:
 
==Using python to regrid your emissions==
 
==Using python to regrid your emissions==
   
  +
For this task we will be using the [http://scitools.org.uk/iris/ Iris] python library, which is developed by the Met Office and can read Met Office formatted files. The [http://cfpython.bitbucket.org/ cf-python] library also does this, but we will not be using this here.
You can use Iris on ARCHER by
 
  +
  +
You can use Iris on ARCHER by loading the [https://www.continuum.io/anaconda-overview anaconda] module:
   
 
module load anaconda
 
module load anaconda
Line 25: Line 27:
 
you will see that Iris is available:
 
you will see that Iris is available:
   
iris 1.8.0 nppy27_1 scitools
+
iris 1.10.0 np19py27_2 https://conda.binstar.org/scitools
  +
 
when using python, a good alias to use is
+
when developing python scripts, a good command to use can be set by the following alias:
   
 
alias pylab='ipython --pylab --logfile=ipython-`date +"%Y%m%d-%H%M%S"`.py'
 
alias pylab='ipython --pylab --logfile=ipython-`date +"%Y%m%d-%H%M%S"`.py'
  +
  +
This uses [http://ipython.readthedocs.io/en/stable/ ipython], which is an interactive shell for python. The <code>--pylab</code> automatically loads some standard python libraries such as [https://www.scipy.org/ scipy], [http://www.numpy.org/ numpy], and [http://matplotlib.org/ matplotlib]. The <code>--logfile</code> means that all commands will be recorded in a file with the format <code>ipython-YYYYMMDD-HHMMSS.py</code>.
  +
  +
You can also execute python scripts by
  +
  +
python2.7 -c "execfile('<span style="color:blue">name_of_script.py</span>')"
  +
  +
'''Don't Panic'''. You are not expected to know python to complete this tutorial. You will be provided with
   
 
Use python script supplied to create emissions netCDF from supplied 0.5x0.5 emissions dataset.
 
Use python script supplied to create emissions netCDF from supplied 0.5x0.5 emissions dataset.

Revision as of 12:37, 25 November 2016

UKCA Chemistry and Aerosol Tutorials at vn10.4

What you will learn in this Tutorial

During this tutorial you will learn how to make new UKCA netCDF emissions files. Then you will learn how to add new emissions into UKCA so that they emit into one of your new tracers.

At the end of the previous tutorial you will now know how to create new tracers for use by UKCA. However, after completing the tasks, your tracers will still be empty, as nothing has been put into them. This tutorial will teach you how to create an emissions file that the UKCA will read, and that you can then tell UKCA to use and emit into your tracer(s).

This tutorial will go through the steps needed to make an emission into a tracer which UKCA does not currently emit into. The steps in making the netCDF file will be the same for a species which is currently emitted into, although in this simpler case you would not need to make any code changes.

Task 5.1: Create a new emissions file and use it in your job

Task 5.1: In the
/work/n02/n02/ukca/Tutorial/vn10.4/Task5.1
directory on ARCHER there is the file Emissions_of_ALICE.nc which is a 0.5x0.5 degree resolution surface emission field. You should regrid this file to the N96 ENDGame grid, and output it as a netCDF file that has the required netCDF metadata for a climatological surface emission without any diurnal cycle.

Using python to regrid your emissions

For this task we will be using the Iris python library, which is developed by the Met Office and can read Met Office formatted files. The cf-python library also does this, but we will not be using this here.

You can use Iris on ARCHER by loading the anaconda module:

module load anaconda

if you then

conda list

you will see that Iris is available:

iris                      1.10.0               np19py27_2    https://conda.binstar.org/scitools

when developing python scripts, a good command to use can be set by the following alias:

alias pylab='ipython --pylab --logfile=ipython-`date +"%Y%m%d-%H%M%S"`.py'

This uses ipython, which is an interactive shell for python. The --pylab automatically loads some standard python libraries such as scipy, numpy, and matplotlib. The --logfile means that all commands will be recorded in a file with the format ipython-YYYYMMDD-HHMMSS.py.

You can also execute python scripts by

python2.7 -c "execfile('name_of_script.py')"

Don't Panic. You are not expected to know python to complete this tutorial. You will be provided with

Use python script supplied to create emissions netCDF from supplied 0.5x0.5 emissions dataset.

Do not need to write script from scratch, just read-through script and try to understand what it does, and why.

Then include in Rose, and also make branch changes:

[16:10:16 luke@puma vn10.4_UKCA_Tutorials]$ fcm diff https://code.metoffice.gov.uk/svn/um/main/branches/dev/lukeabraham/vn10.4_UKCA_Tutorials@28917 https://code.metoffice.gov.uk/svn/um/main/branches/dev/lukeabraham/vn10.4_UKCA_Tutorials@29446
Index: src/atmosphere/UKCA/ukca_setd1defs.F90
===================================================================
--- src/atmosphere/UKCA/ukca_setd1defs.F90      (revision 28917)
+++ src/atmosphere/UKCA/ukca_setd1defs.F90      (revision 29446)
@@ -301,7 +301,7 @@
       nr_phot         = 38
     END IF
   ELSE IF (L_ukca_strattrop .AND. .NOT. L_ukca_achem) THEN
-    n_chem_emissions = 9
+    n_chem_emissions = 10
     n_3d_emissions = 1       ! aircraft NOX
     n_aero_tracers =  0
     ALLOCATE(em_chem_spec(n_chem_emissions+n_3d_emissions))
@@ -308,19 +308,20 @@
     em_chem_spec =                                             &
         (/'NO        ','CH4       ','CO        ','HCHO      ', &
           'C2H6      ','C3H8      ','Me2CO     ','MeCHO     ', &
-          'C5H8      ','NO_aircrft'/)
+          'C5H8      ','ALICE     ','NO_aircrft'/)
     n_chem_tracers = 73         ! No chem tracers
     nr_therm       = 220        ! thermal reactions
     nr_phot        = 55         ! photolytic (ATA)
 
   ELSE IF (L_ukca_strattrop .AND. L_ukca_achem) THEN
-    n_chem_emissions = 19      ! em_chem_spec below
+    n_chem_emissions = 20      ! em_chem_spec below
     n_3d_emissions   = 4       ! BC, OC, volc SO2 & aircraft NOX
     ALLOCATE(em_chem_spec(n_chem_emissions+n_3d_emissions))
     em_chem_spec =                                             &
         (/'NO        ','CH4       ','CO        ','HCHO      ', &
           'C2H6      ','C3H8      ','Me2CO     ','MeCHO     ', &
-          'C5H8      ','BC_fossil ','BC_biofuel','OC_fossil ', &
+          'C5H8      ','ALICE     ',                           &
+          'BC_fossil ','BC_biofuel','OC_fossil ',              &
           'OC_biofuel','Monoterp  ','NVOC      ','SO2_low   ', &
           'SO2_high  ','NH3       ','DMS       ','SO2_nat   ', &
           'BC_biomass','OC_biomass','NO_aircrft'/)
@@ -715,6 +716,8 @@
       UkcaD1Codes(j+i)%item = 314
     ELSE IF (em_chem_spec(i) == 'NVOC      ') THEN
       UkcaD1Codes(j+i)%item = 315
+    ELSE IF (em_chem_spec(i) == 'ALICE     ') THEN
+      UkcaD1Codes(j+i)%item = 316
     ELSE IF (em_chem_spec(i) == 'BC_biomass') THEN
       UkcaD1Codes(j+i)%item = 322
       UkcaD1Codes(j+i)%len_dim3 = tr_levels
Index: src/atmosphere/UKCA/get_molmass_mod.F90
===================================================================
--- src/atmosphere/UKCA/get_molmass_mod.F90     (revision 28917)
+++ src/atmosphere/UKCA/get_molmass_mod.F90     (revision 29446)
@@ -242,6 +242,9 @@
 CASE ('BrCl      ')
   get_molmass = m_brcl
 
+CASE ('ALICE     ')
+  get_molmass = m_ALICE
+
   ! -----------------------------------------
   !   Others (report warning)
 CASE ('AGE       ')
Index: src/atmosphere/UKCA/ukca_constants.F90
===================================================================
--- src/atmosphere/UKCA/ukca_constants.F90      (revision 28917)
+++ src/atmosphere/UKCA/ukca_constants.F90      (revision 29446)
@@ -390,6 +390,9 @@
 REAL, PARAMETER :: m_aromooh  = 130.0
 REAL, PARAMETER :: m_mekooh   = 104.0
 
+!     UKCA Tutorial tracers - only ALICE is emitted
+REAL, PARAMETER :: m_ALICE    = 1.0000  
+
 !     The mass of organic nitrate is an approximation,
 !     calculated as the average of ORGNIT formed by two
 !     reacs. in UKCA_CHEMCO_RAQ:
Index: src/atmosphere/UKCA/ukca_chem_strattrop.F90
===================================================================
--- src/atmosphere/UKCA/ukca_chem_strattrop.F90 (revision 28917)
+++ src/atmosphere/UKCA/ukca_chem_strattrop.F90 (revision 29446)
@@ -215,7 +215,7 @@
 !  75
 chch_t( 75,'N2        ',  1,'CT        ','          ',  0,  0,  0),  &
 !  76 
-chch_t( 88,'ALICE     ',  1,'TR        ','          ',  0,  0,  0),  &
+chch_t( 88,'ALICE     ',  1,'TR        ','          ',  0,  0,  1),  &
 !  77 
 chch_t( 89,'BOB       ',  1,'TR        ','          ',  0,  0,  0)   &
   /)
@@ -372,7 +372,7 @@
 !  75
 chch_t( 75,'N2        ',  1,'CT        ','          ',  0,  0,  0),  &
 !  76 
-chch_t( 88,'ALICE     ',  1,'TR        ','          ',  0,  0,  0),  &
+chch_t( 88,'ALICE     ',  1,'TR        ','          ',  0,  0,  1),  &
 !  77 
 chch_t( 89,'BOB       ',  1,'TR        ','          ',  0,  0,  0),  &
 !  78

Note: may also need to technically make changes to old emissions routines. However, job runs as is. May not need to make changes to STASH block in ukca_setd1defs.F90, as this is for old scheme.