forked from KirstyPringle/UKCA_postproc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUKCA_ControlFile.py
executable file
·154 lines (117 loc) · 4.91 KB
/
UKCA_ControlFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# -*- coding: utf-8 -*-
"""
Control file for L0 and L1 processing
"""
import os
import sys
import getpass
from glob import glob
import logging
import datetime
#%%
try:
sys.path.append('/nfs/a107/eejvt/PYTHON_CODE')
import Jesuslib as jl
except:
print 'Jesuslib not accesible'
########################################################
## Key user defined settings.
####IMPORTANT####
#dir_scripts='/nfs/see-fs-01_users/eejvt/CASIM_postproc/'
dir_scripts='/home/users/kpringle/DataVisualisation/AerVis/UKCA_postproc/'
# This is the directory where the code is. Change it to the path where you downloaded the file
####IMPORTANT####
# Which model would you like to read data from? Options are: UKCA, TOMCAT_GLOMAP or CASIM
model_name = "CASIM"
model_name = "UKCA"
#model_name = "TOMCAT_GLOMAP"
jobID = "whatever"
jobID = "tebiz"
#jobID = "glo301"
run_L0=True # if true will convert raw output to Level1 nc files.
#run_L0=0
run_L1=True # if true will calculate additional output as a postprocessing step e.g. CCN
run_plots=False # if true will produce a series of standard plots
send_mail=True # ?
## Key user defined paths
#dir_scripts='/nfs/a107/earkpr/DataVisualisation/Jesus/git_area/UKCA_postproc-master/'
#orog_file = '/group_workspaces/jasmin2/gassp/jvergaratemprado/n96_hadgem1_qrparm.orog_new.pp'
#jasminorog_file = '/nfs/a107/earkpr/ACID-PRUFF/Masaru/OAT5/teafw/ppfiles/n96_hadgem1_qrparm.orog_new.pp'#leeds foe-linux
## Automatically defined paths
username=getpass.getuser()
LOGFILES_Directory_Path = dir_scripts+'LOGFILES/'
## Location of the pp files (raw data files)
#The location can be given as an argument when you call the script (ipython UKCA_ControlFile.py /nfs/a201/...../) or
#it can be given as:
# input_files_directory='/nfs/a201/'+str(username)+'/'+str(model_name)+'_TEST_FILES/'+str(jobID)+'/'
#or just as:
if len(sys.argv)>1:
input_files_directory=sys.argv[1]
if input_files_directory[-1]!='/':
input_files_directory=input_files_directory+'/'
try:
run_L0=int(sys.argv[2])
run_L1=int(sys.argv[3])
run_plots=int(sys.argv[4])
print 'run booleans writen from command line'
print run_L0,run_L1,run_plots
except:
asdfasdf=3452
else:
input_files_directory='/nfs/a201/eejvt/CASIM/SO_KALLI/NO_CLOUD_SQUEME/GP_HIGH_CSED/'
input_files_directory='/nfs/a201/eejvt/CASIM/SECOND_CLOUD/GP_HAM_DMDUST/'
#input_files_directory='/nfs/a201/eejvt/CASIM/SO_KALLI/TRY2/2_ORD_LESS/'
## Location of where to write Level 0 (data files in nc format). Typically will be the same as input_files_directory.
# output_files_directory='/nfs/a201/'+str(username)+'/'+str(model_name)+'_TEST_FILES/'+str(jobID)+'/'
output_files_directory=input_files_directory
## Set path to look in dir_scripts for Python routines
sys.path.append(dir_scripts)
########################################################
#%% Setting that shouldn't be edited by users very often
################################################
# For UKCA runs, need to also define an orography file.
if model_name is "UKCA":
orog_file = '/nfs/a107/earkpr/ACID-PRUFF/Masaru/OAT5/teafw/ppfiles/n96_hadgem1_qrparm.orog_new.pp'
# Setup the level of logging information required
# Options are: DEBUG (most info), WARNING, INFO (least info)
# Default is: DEBUG
if not os.path.exists(LOGFILES_Directory_Path):
os.makedirs(LOGFILES_Directory_Path)
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
log = logging.getLogger()
hdlr = logging.FileHandler(LOGFILES_Directory_Path+'/Log_'+str(jobID)+'_'+sys.argv[0].split('/')[-1][:-3]+'_'+str(now).replace(' ', '_')+'.log')
##FORMAT='%(asctime)s\t%(levelname)s\t%(message)s'
FORMAT='%(levelname)s\t%(message)s'
formatter = logging.Formatter(FORMAT)
logging.basicConfig(format=FORMAT) # log sur console
hdlr.setFormatter(formatter)
log.addHandler(hdlr)
log.setLevel(logging.DEBUG) #set verbosity to show all messages of severity >= DEBUG
#log.setLevel(logging.WARNING) #set verbosity to show all messages of severity >= DEBUG
#log.setLevel(logging.INFO) #set verbosity to show all messages of severity >= DEBUG
log.info('START OF LOGGING')
log.info('================')
log.info('username = '+str(username))
log.info("jobID = "+str(jobID))
log.info("input_files_directory = "+str(input_files_directory))
log.info("output_files_directory = "+str(output_files_directory))
if run_L0:
if model_name == "TOMCAT_GLOMAP":
execfile("L0_processing_TOMCAT_GLOMAP.py")
elif model_name == "CASIM":
execfile("L0_processing_CASIM.py")
else:
execfile("L0_processing.py")
if run_L1:
if model_name == "CASIM":
execfile("L1_processing_CASIM.py")
else:
execfile("L1_processing.py")
if run_plots:
execfile("Plots_for_netCDF4.py")
#if send_mail:
# jl.send_email()
##log.flush()
#log.removeHandler(hdlr)
#hdlr.close()
################################################