source: palm/trunk/UTIL/WRF_interface/dynamic/palm_dynamic_init.py @ 4871

Last change on this file since 4871 was 4843, checked in by raasch, 4 years ago

local namelist parameter added to switch off the module although the respective module namelist appears in the namelist file, further copyright updates

File size: 4.2 KB
Line 
1#!/usr/bin/python3
2# -*- coding: utf-8 -*-
3
4#------------------------------------------------------------------------------#
5#
6# Scripts for processing of WRF and CAMx files to PALM dynamic driver
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program.  If not, see <https://www.gnu.org/licenses/>.
20#
21# Copyright 2018-2021 Institute of Computer Science
22#                     of the Czech Academy of Sciences, Prague
23# Authors: Krystof Eben, Jaroslav Resler, Pavel Krc
24#
25#------------------------------------------------------------------------------#
26'''
27This file provides initialization of the basic variables and structures base on
28the default and user config values. It can be adjusted to the needs of particular
29user system or structure of the data storage.
30'''
31
32import os
33from pathlib import Path
34import numpy as np
35
36# paths of directories
37dir_base = os.path.abspath(Path(dir_scripts).parent.parent)
38print('Base dir:', dir_base)
39dir_in = os.path.join(dir_base, domain)
40print('Input dir:', dir_in)
41if scenario == '':
42    dir_in_scen = dir_in
43else:
44    dir_in_scen = os.path.join(dir_in,scenario)
45    print('Scenario input dir:', dir_in_scen)
46dir_out = os.path.join(dir_base, domain)
47print('Output dir:', dir_out)
48
49# file names of PALM PIDS drivers
50# extension of file name for scenario
51scenario_ext = ("_"+scenario if scenario != "" else "")
52# static driver netcdf file name
53if static_driver_file == "":
54    static_driver_file = os.path.join(dir_out, domain+"_static_driver"+"_d"+resolution+scenario_ext+".nc")
55# dynamic driver netcdf file name
56if dynamic_driver_file == "":
57    dynamic_driver_file = os.path.join(dir_out, domain+"_dynamic_driver"+"_d"+resolution+scenario_ext+".nc")
58
59# parameters of dynamic driver
60# minimal number of free surface canopy layers above top of terrain with building and plant canopy
61nscl_free = 3
62# default path of wrf files in case it is not set in user config
63if wrf_dir_name == '':
64    wrf_dir_name = os.path.join(dir_in, 'wrf')
65
66# Settings for geostrophic wind
67gw_gfs_margin_deg = 5. #smoothing area in degrees lat/lon
68gw_wrf_margin_km = 10. #smoothing area in km
69#gw_alpha = .143 #GW vertical interpolation by power law
70gw_alpha = 1. #ignore wind power law, interpolate linearly
71
72
73# chemical initial and boundary coords - CAMx nesting
74# CAMx variable conversions
75camx_conversions = {
76        'NO':  dict(
77            camx_vars = ['NO'],
78            camx_units = ['ppmv'],
79            output_unit = 'ppm',
80            formula = lambda no, hlp: no,
81            ),
82        'NO2':  dict(
83            camx_vars = ['NO2'],
84            camx_units = ['ppmv'],
85            output_unit = 'ppm',
86            formula = lambda no2, hlp: no2,
87            ),
88        'NOX': dict(
89            camx_vars=['NO', 'NO2'],
90            camx_units=['ppmv', 'ppmv'],
91            output_unit='ppm',
92            formula=lambda no, no2, hlp: no + no2,
93        ),
94        'O3':  dict(
95            camx_vars = ['O3'],
96            camx_units = ['ppmv'],
97            output_unit = 'ppm',
98            formula = lambda o3, hlp: o3,
99            ),
100        'PM10':  dict(
101            camx_vars = ['CPRM'],
102            camx_units = ['micrograms m-3'],
103            output_unit = 'kg/m3',
104            formula = lambda cprm, hlp: (cprm+hlp.pm25) * 1e-9,
105            ),
106        'PM25':  dict(
107            camx_vars = [],
108            camx_units = [],
109            output_unit = 'kg/m3',
110            formula = lambda hlp: hlp.pm25 * 1e-9,
111            ),
112        }
113
114camx_helpers = [
115        ('pm25',  dict(
116            camx_vars = 'PSO4 PNO3 PNH4 POA PEC FPRM SOA1 SOA2 SOA3 SOA4 SOPA SOPB'.split(),
117            camx_units = ['micrograms m-3']*12,
118            formula = lambda *args: np.sum(args[:-1], axis=0), #last arg is hlp
119            )),
120        ]
121
122
Note: See TracBrowser for help on using the repository browser.