Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion preprocessor/code_bashinterface/work_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import rst_import


def sec1_user_config(tag_af, af_fnames, year_rst):
def sec1_user_config(tag_af, af_fnames, year_rst, export_frp=True):
""" hard-wired options"""


Expand Down Expand Up @@ -130,6 +130,17 @@ def sec1_user_config(tag_af, af_fnames, year_rst):
},
]

if export_frp:
tag_frp = 'frp'
rasters.append(
{
'tag': tag_frp,
'kind': 'input',
'variable_in': 'frp',
'variable': 'frp',
})


# save *.shp of the output, so that you can hold onto polygons
save_shp_of_output = True

Expand Down
23 changes: 16 additions & 7 deletions preprocessor/code_bashinterface/work_nrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,17 @@ def sec6_process_activefire(first_day=None, last_day=None, run_step1=True, run_s
print(f'\n{this_script_name}: Skipping step2\n')


def sec7_export_output(out_dir, summary_file=None):
shpname = 'out_{0}_{1}_{2}_{3}.shp'.format(tag_af, tag_lct, tag_vcf, tag_regnum)
def sec7_export_output(out_dir, summary_file=None, export_frp=True):

schema = 'af_' + tag_af
tblname = 'out_{0}_{1}_{2}'.format(tag_lct, tag_vcf, tag_regnum)
flds = ('v_lct', 'f_lct', 'v_tree', 'v_herb', 'v_bare', 'v_regnum')
if export_frp:
shpname = 'out_{0}_{1}_{2}_{3}_{4}.shp'.format(tag_af, tag_lct, tag_vcf, tag_regnum, tag_frp)
tblname = 'out_{0}_{1}_{2}_{3}'.format(tag_lct, tag_vcf, tag_regnum, tag_frp)
flds = ('v_lct', 'f_lct', 'v_tree', 'v_herb', 'v_bare', 'v_regnum', 'v_frp')
else:
shpname = 'out_{0}_{1}_{2}_{3}.shp'.format(tag_af, tag_lct, tag_vcf, tag_regnum)
tblname = 'out_{0}_{1}_{2}'.format(tag_lct, tag_vcf, tag_regnum)
flds = ('v_lct', 'f_lct', 'v_tree', 'v_herb', 'v_bare', 'v_regnum')

export_shp.main(out_dir, schema, tblname, flds, shpname,
date_definition = date_definition)
Expand All @@ -183,7 +188,7 @@ def sec7_export_output(out_dir, summary_file=None):

# TODO have '-f' option to clean the schema. otherwise it wont overwrite or do anything and die
def main(tag_af, af_fnames, year_rst, out_dir, first_day=None, last_day=None,
summary_file=None, run_import=True, run_step1=True, run_step2=True):
summary_file=None, run_import=True, run_step1=True, run_step2=True, export_frp=True):

out_dir = Path(out_dir)
out_dir.mkdir(parents=True, exist_ok=True)
Expand All @@ -197,7 +202,7 @@ def main(tag_af, af_fnames, year_rst, out_dir, first_day=None, last_day=None,

print(f'\n{this_script_name}: Starting processing ...\n')

user_config = common.sec1_user_config(tag_af, af_fnames, year_rst)
user_config = common.sec1_user_config(tag_af, af_fnames, year_rst, export_frp)
globals().update(user_config)

common.sec2_check_environment(out=out)
Expand All @@ -215,7 +220,7 @@ def main(tag_af, af_fnames, year_rst, out_dir, first_day=None, last_day=None,
summary_file = Path(summary_file).open('a')

print(f'\n{this_script_name}: Starting export ...\n')
sec7_export_output(out_dir=out_dir, summary_file=summary_file)
sec7_export_output(out_dir=out_dir, summary_file=summary_file, export_frp=export_frp)



Expand Down Expand Up @@ -265,6 +270,10 @@ def str2bool(v):
help='run step2 (lct/vcf identification) [yes/no]',
type=str2bool, nargs='?', const=True)

parser.add_argument('--export_frp', default=True,
help='export average frp at each polygon [yes/no]',
type=str2bool, nargs='?', const=True)

parser.add_argument('af_fnames',
default=None, nargs='+', help='AF file name(s)', type=str)

Expand Down
14 changes: 7 additions & 7 deletions preprocessor/work_nrt/demo_nrt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ python3 $exc_dir/work_nrt.py -t $tag -y $yrm2 \
-o $out_dir \
-fd $yj -ld $yj \
-s $summary_file \
$data_dir/FIRMS/modis-c6.1/MODIS_C6_Global_MCD14DL_NRT_${yjm1}.txt \
$data_dir/FIRMS/modis-c6.1/MODIS_C6_Global_MCD14DL_NRT_${yj}.txt \
$data_dir/FIRMS/suomi-npp-viirs-c2/SUOMI_VIIRS_C2_Global_VNP14IMGTDL_NRT_${yjm1}.txt \
$data_dir/FIRMS/suomi-npp-viirs-c2/SUOMI_VIIRS_C2_Global_VNP14IMGTDL_NRT_${yj}.txt
$data_dir/FIRMS/modis-c6.1/Global/MODIS_C6_1_Global_MCD14DL_NRT_${yjm1}.txt \
$data_dir/FIRMS/modis-c6.1/Global/MODIS_C6_1_Global_MCD14DL_NRT_${yj}.txt \
$data_dir/FIRMS/suomi-npp-viirs-c2/Global/SUOMI_VIIRS_C2_Global_VNP14IMGTDL_NRT_${yjm1}.txt \
$data_dir/FIRMS/suomi-npp-viirs-c2/Global/SUOMI_VIIRS_C2_Global_VNP14IMGTDL_NRT_${yj}.txt

if [ $? -ne 0 ]; then
echo problem in work_nrt.py
exit 2
fi

# Purge the intermediate results in the database
python3 $exc_dir/work_clean.py -t $tag \
-s $summary_file
## Purge the intermediate results in the database
#python3 $exc_dir/work_clean.py -t $tag \
# -s $summary_file


if [ $? -ne 0 ]; then
Expand Down