<commit_before># ocean_summary_base.mk
#
# Description: Core workflow for producing ocean summary data:
#  - zonal mean ocean temperature and salinity fields
#  - vertical mean ocean temperature and salinity fields
#  - ocean heat content fields and timeseries 
#
# To execute:
#   1. copy name of target file from ocean_summary_base.mk 
#   2. paste it into ocean_summary_config.mk as the target variable  
#   3. $ make -n -B -f ocean_summary_base.mk  (-n is a dry run) (-B is a force make)


# Define marcos

include ocean_summary_config.mk
all : ${TARGET}

# Filenames

CONTROL_FILES=$(wildcard ${ORIG_CONTROL_DIR}/${ORGANISATION}/${MODEL}/piControl/mon/ocean/${VAR}/${CONTROL_RUN}/${VAR}_Omon_${MODEL}_piControl_${CONTROL_RUN}_*.nc)
CONTROL_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/piControl/yr/ocean/${VAR}/${CONTROL_RUN}
DRIFT_COEFFICIENTS=${CONTROL_DIR}/${VAR}-coefficients_Oyr_${MODEL}_piControl_${CONTROL_RUN}_all.nc

VARIABLE_FILES=$(wildcard ${ORIG_VARIABLE_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/ocean/${VAR}/${RUN}/${VAR}_Omon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)

DEDRIFTED_VARIABLE_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/${VAR}/${RUN}/dedrifted
DEDRIFTED_VARIABLE_FILES = $(patsubst ${ORIG_VARIABLE_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/ocean/${VAR}/${RUN}/${VAR}_Omon_%.nc, ${DEDRIFTED_VARIABLE_DIR}/${VAR}_Oyr_%.nc, ${VARIABLE_FILES})

VOLUME_FILE=${ORIG_VOL_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/ocean/volcello/${FX_RUN}/volcello_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc
BASIN_FILE=${ORIG_BASIN_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/ocean/basin/${FX_RUN}/basin_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc
DEPTH_FILE=${ORIG_DEPTH_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/ocean/deptho/${FX_RUN}/deptho_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc
ATMOS_AREA_FILE=${ORIG_AREAA_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/atmos/areacella/${FX_RUN}/areacella_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc
OCEAN_AREA_FILE=${ORIG_AREAO_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/ocean/areacello/${FX_RUN}/areacello_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc

TAS_FILE=$(wildcard ${ORIG_TAS_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/atmos/tas/${RUN}/tas_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)
GLOBAL_MEAN_TAS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/atmos/tas/${RUN}
GLOBAL_MEAN_TAS_FILE=${GLOBAL_MEAN_TAS_DIR}/tas-global-mean_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

SOS_FILE=$(wildcard ${ORIG_SOS_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/ocean/sos/${RUN}/sos_Omon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)
GLOBAL_AMP_SOS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/sos/${RUN}
GLOBAL_AMP_SOS_FILE=${GLOBAL_AMP_SOS_DIR}/sos-global-amp_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
SOS_CLIM_FILE=${GLOBAL_AMP_SOS_DIR}/sos-clim_Omon_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
GLOBAL_MYAMP_SOS_FILE=${GLOBAL_AMP_SOS_DIR}/sos-global-myamp_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

PR_FILE=$(wildcard ${ORIG_PR_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/atmos/pr/${RUN}/pr_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)
GLOBAL_MEAN_PR_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/atmos/pr/${RUN}
GLOBAL_MEAN_PR_FILE=${GLOBAL_MEAN_PR_DIR}/pr-global-mean_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

EVSPSBL_DIR=${ORIG_EVSPSBL_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/atmos/evspsbl/${RUN}
EVSPSBL_FILE=$(wildcard ${EVSPSBL_DIR}/evspsbl_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)
GLOBAL_MEAN_EVSPSBL_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/atmos/evspsbl/${RUN}
GLOBAL_MEAN_EVSPSBL_FILE=${GLOBAL_MEAN_EVSPSBL_DIR}/evspsbl-global-mean_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

PE_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/atmos/pe/${RUN}
PE_FILE=${PE_DIR}/pe_Amon_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
GLOBAL_ABS_PE_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/atmos/pe/${RUN}
GLOBAL_ABS_PE_FILE=${GLOBAL_ABS_PE_DIR}/pe-global-abs_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

GLOBAL_INDICATORS_PLOT=${MY_DATA_DIR}/figures/global_indicators/global-indicators_${MODEL}_${EXPERIMENT}_${RUN}.png

VARIABLE_MAPS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/${VAR}-maps/${RUN}
VARIABLE_MAPS_FILE=${VARIABLE_MAPS_DIR}/${VAR}-maps_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
VARIABLE_MAPS_TIME_TREND=${VARIABLE_MAPS_DIR}/${VAR}-maps-time-trend_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.nc
VARIABLE_MAPS_TAS_TREND=${VARIABLE_MAPS_DIR}/${VAR}-maps-global-tas-trend_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.nc
VARIABLE_MAPS_TIME_VERTICAL_PLOT=${VARIABLE_MAPS_DIR}/${VAR}-maps-time-trend-vertical-mean_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}
VARIABLE_MAPS_TIME_ZONAL_PLOT=${VARIABLE_MAPS_DIR}/${VAR}-maps-time-trend-zonal-mean_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}
VARIABLE_MAPS_TAS_VERTICAL_PLOT=${VARIABLE_MAPS_DIR}/${VAR}-maps-global-tas-trend-vertical-mean_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}
VARIABLE_MAPS_TAS_ZONAL_PLOT=${VARIABLE_MAPS_DIR}/${VAR}-maps-global-tas-trend-zonal-mean_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}

CLIMATOLOGY_FILE=${DEDRIFTED_VARIABLE_DIR}/${VAR}-clim_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
CLIMATOLOGY_MAPS_FILE=${VARIABLE_MAPS_DIR}/${VAR}-maps-clim_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

OHC_METRICS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/${METRIC}/${RUN}
OHC_METRICS_FILE=${OHC_METRICS_DIR}/${METRIC}_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
OHC_METRICS_PLOT=${OHC_METRICS_DIR}/${METRIC}_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.${FIG_TYPE}

OHC_MAPS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/ohc-maps/${RUN}
OHC_MAPS_FILE=${OHC_MAPS_DIR}/ohc-maps_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
OHC_MAPS_PLOT=${OHC_MAPS_DIR}/ohc-maps_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}


# De-drift

${DRIFT_COEFFICIENTS} :
	mkdir -p ${CONTROL_DIR} 
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_drift_coefficients.py ${CONTROL_FILES} $@ --var ${LONG_NAME} --annual

${DEDRIFTED_VARIABLE_DIR} : ${DRIFT_COEFFICIENTS}
	mkdir -p $@
	${PYTHON} ${DATA_SCRIPT_DIR}/remove_drift.py ${VARIABLE_FILES} ${LONG_NAME} $< $@/ --annual 
        #--no_parent_check

# Core data

${CLIMATOLOGY_FILE} : ${DEDRIFTED_VARIABLE_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_climatology.py ${DEDRIFTED_VARIABLE_FILES} ${LONG_NAME} $@

# Variable maps

${VARIABLE_MAPS_FILE} : ${CLIMATOLOGY_FILE}
	mkdir -p ${VARIABLE_MAPS_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_ocean_maps.py ${DEDRIFTED_VARIABLE_FILES} ${LONG_NAME} $@ --climatology_file $<
        #--chunk x --basin_file ${BASIN_FILE} --depth_file ${DEPTH_FILE}

${CLIMATOLOGY_MAPS_FILE} : ${CLIMATOLOGY_FILE}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_ocean_maps.py $< ${LONG_NAME} $@ 
        # --basin_file ${BASIN_FILE}  --depth_file ${DEPTH_FILE}

${VARIABLE_MAPS_TIME_TREND} : ${VARIABLE_MAPS_FILE}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_trend.py $< $@ --time_bounds ${START_DATE} ${END_DATE}

${VARIABLE_MAPS_TIME_VERTICAL_PLOT} : ${VARIABLE_MAPS_TIME_TREND}
	${PYTHON} ${VIS_SCRIPT_DIR}/plot_ocean_trend.py $< ${LONG_NAME} vertical_mean $@ --scale_factor ${SCALE_FACTOR} --vm_tick_scale 4 1 2 2 6 --palette ${PALETTE} --vm_ticks ${VM_TICK_MAX} ${VM_TICK_STEP}

${VARIABLE_MAPS_TIME_ZONAL_PLOT} : ${VARIABLE_MAPS_TIME_TREND} ${CLIMATOLOGY_MAPS_FILE}
	${PYTHON} ${VIS_SCRIPT_DIR}/plot_ocean_trend.py $< ${LONG_NAME} zonal_mean $@ --scale_factor ${SCALE_FACTOR} --palette ${PALETTE} --climatology_file $(word 2,$^) --zm_ticks ${ZM_TICK_MAX} ${ZM_TICK_STEP}

# Trends against global mean temperature

${GLOBAL_MEAN_TAS_FILE} :  
	mkdir -p ${GLOBAL_MEAN_TAS_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py ${TAS_FILE} air_temperature mean $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${VARIABLE_MAPS_TAS_TREND} : ${VARIABLE_MAPS_FILE} ${GLOBAL_MEAN_TAS_FILE} 
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_trend.py $< $@ --time_bounds ${START_DATE} ${END_DATE} --xaxis $(word 2,$^) air_temperature

${VARIABLE_MAPS_TAS_VERTICAL_PLOT} : ${VARIABLE_MAPS_TAS_TREND}
	${PYTHON} ${VIS_SCRIPT_DIR}/plot_ocean_trend.py $< ${LONG_NAME} vertical_mean $@  --vm_ticks ${VM_TICK_MAX} ${VM_TICK_STEP} --vm_tick_scale 4 1 2 2 6 --palette ${PALETTE} 

${VARIABLE_MAPS_TAS_ZONAL_PLOT} : ${VARIABLE_MAPS_TAS_TREND} ${CLIMATOLOGY_MAPS_FILE}
	${PYTHON} ${VIS_SCRIPT_DIR}/plot_ocean_trend.py $< ${LONG_NAME} zonal_mean $@ --palette ${PALETTE} --climatology_file $(word 2,$^) --zm_ticks ${ZM_TICK_MAX} ${ZM_TICK_STEP}

## Use ocean_summary_ensembles.sh if more than one run
## Use plot_trend_comparison.sh to compare GHG to AA
## Use plot_ocean_trend_ensemble.sh to plot same basin for entire ensemble

# Global indicators

${PE_DIR} :
	mkdir -p $@
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_pe.py ${PR_FILE} precipitation_flux ${EVSPSBL_DIR} water_evaporation_flux $@

${GLOBAL_ABS_PE_FILE} : ${PE_DIR}
	mkdir -p ${GLOBAL_ABS_PE_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py $(wildcard ${PE_DIR}/pe_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc) precipitation_minus_evaporation_flux mean-abs $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${GLOBAL_AMP_SOS_FILE} :  
	mkdir -p ${GLOBAL_AMP_SOS_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py ${SOS_FILE} sea_surface_salinity amplification $@ --area_file ${OCEAN_AREA_FILE} --smoothing annual

${SOS_CLIM_FILE} :
	mkdir -p ${GLOBAL_AMP_SOS_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_climatology.py ${SOS_FILE} sea_surface_salinity $@

${GLOBAL_MYAMP_SOS_FILE} : ${SOS_CLIM_FILE}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_my_salinity_amp.py ${SOS_FILE} sea_surface_salinity $< $@ --area_file ${OCEAN_AREA_FILE} --smoothing annual

${GLOBAL_MEAN_PR_FILE} :  
	mkdir -p ${GLOBAL_MEAN_PR_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py ${PR_FILE} precipitation_flux mean $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${GLOBAL_MEAN_EVSPSBL_FILE} :  
	mkdir -p ${GLOBAL_MEAN_EVSPSBL_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py ${EVSPSBL_FILE} water_evaporation_flux mean $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${GLOBAL_INDICATORS_PLOT} : ${GLOBAL_MEAN_TAS_FILE} ${GLOBAL_AMP_SOS_FILE} ${GLOBAL_ABS_PE_FILE}
	echo $@

        ## e.g. python plot_global_indicators.py /g/data/r87/dbi599/drstree/CMIP5/GCM/IPSL/IPSL-CM5A-LR/*/yr/ocean/sos/*/sos-global-amp_Oyr_IPSL-CM5A-LR_*_*_*.nc /g/data/r87/dbi599/drstree/CMIP5/GCM/IPSL/IPSL-CM5A-LR/*/yr/*/*/*/*global-mean_Ayr_IPSL-CM5A-LR_*_*_*.nc /g/data/r87/dbi599/figures/global_indicators/global-indcators_yr_IPSL-CM5A-LR_historicalAll_r1i1_all.png --aa_physics 3 --ant_physics 2
<commit_msg>Added pe amp<commit_after># ocean_summary_base.mk
#
# Description: Core workflow for producing ocean summary data:
#  - zonal mean ocean temperature and salinity fields
#  - vertical mean ocean temperature and salinity fields
#  - ocean heat content fields and timeseries 
#
# To execute:
#   1. copy name of target file from ocean_summary_base.mk 
#   2. paste it into ocean_summary_config.mk as the target variable  
#   3. $ make -n -B -f ocean_summary_base.mk  (-n is a dry run) (-B is a force make)


# Define marcos

include ocean_summary_config.mk
all : ${TARGET}

# Filenames

CONTROL_FILES=$(wildcard ${ORIG_CONTROL_DIR}/${ORGANISATION}/${MODEL}/piControl/mon/ocean/${VAR}/${CONTROL_RUN}/${VAR}_Omon_${MODEL}_piControl_${CONTROL_RUN}_*.nc)
CONTROL_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/piControl/yr/ocean/${VAR}/${CONTROL_RUN}
DRIFT_COEFFICIENTS=${CONTROL_DIR}/${VAR}-coefficients_Oyr_${MODEL}_piControl_${CONTROL_RUN}_all.nc

VARIABLE_FILES=$(wildcard ${ORIG_VARIABLE_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/ocean/${VAR}/${RUN}/${VAR}_Omon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)

DEDRIFTED_VARIABLE_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/${VAR}/${RUN}/dedrifted
DEDRIFTED_VARIABLE_FILES = $(patsubst ${ORIG_VARIABLE_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/ocean/${VAR}/${RUN}/${VAR}_Omon_%.nc, ${DEDRIFTED_VARIABLE_DIR}/${VAR}_Oyr_%.nc, ${VARIABLE_FILES})

VOLUME_FILE=${ORIG_VOL_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/ocean/volcello/${FX_RUN}/volcello_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc
BASIN_FILE=${ORIG_BASIN_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/ocean/basin/${FX_RUN}/basin_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc
DEPTH_FILE=${ORIG_DEPTH_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/ocean/deptho/${FX_RUN}/deptho_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc
ATMOS_AREA_FILE=${ORIG_AREAA_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/atmos/areacella/${FX_RUN}/areacella_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc
OCEAN_AREA_FILE=${ORIG_AREAO_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/fx/ocean/areacello/${FX_RUN}/areacello_fx_${MODEL}_${EXPERIMENT}_${FX_RUN}.nc

TAS_FILE=$(wildcard ${ORIG_TAS_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/atmos/tas/${RUN}/tas_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)
GLOBAL_MEAN_TAS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/atmos/tas/${RUN}
GLOBAL_MEAN_TAS_FILE=${GLOBAL_MEAN_TAS_DIR}/tas-global-mean_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

SOS_FILE=$(wildcard ${ORIG_SOS_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/ocean/sos/${RUN}/sos_Omon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)
GLOBAL_AMP_SOS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/sos/${RUN}
GLOBAL_AMP_SOS_FILE=${GLOBAL_AMP_SOS_DIR}/sos-global-amp_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
SOS_CLIM_FILE=${GLOBAL_AMP_SOS_DIR}/sos-clim_Omon_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
GLOBAL_MYAMP_SOS_FILE=${GLOBAL_AMP_SOS_DIR}/sos-global-myamp_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

PR_FILE=$(wildcard ${ORIG_PR_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/atmos/pr/${RUN}/pr_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)
GLOBAL_MEAN_PR_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/atmos/pr/${RUN}
GLOBAL_MEAN_PR_FILE=${GLOBAL_MEAN_PR_DIR}/pr-global-mean_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

EVSPSBL_DIR=${ORIG_EVSPSBL_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/atmos/evspsbl/${RUN}
EVSPSBL_FILE=$(wildcard ${EVSPSBL_DIR}/evspsbl_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc)
GLOBAL_MEAN_EVSPSBL_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/atmos/evspsbl/${RUN}
GLOBAL_MEAN_EVSPSBL_FILE=${GLOBAL_MEAN_EVSPSBL_DIR}/evspsbl-global-mean_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

PE_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/mon/atmos/pe/${RUN}
GLOBAL_PE_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/atmos/pe/${RUN}
GLOBAL_ABS_PE_FILE=${GLOBAL_PE_DIR}/pe-global-abs_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
GLOBAL_AMP_PE_FILE=${GLOBAL_PE_DIR}/pe-global-amp_Ayr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

GLOBAL_INDICATORS_PLOT=${MY_DATA_DIR}/figures/global_indicators/global-indicators_${MODEL}_${EXPERIMENT}_${RUN}.png

VARIABLE_MAPS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/${VAR}-maps/${RUN}
VARIABLE_MAPS_FILE=${VARIABLE_MAPS_DIR}/${VAR}-maps_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
VARIABLE_MAPS_TIME_TREND=${VARIABLE_MAPS_DIR}/${VAR}-maps-time-trend_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.nc
VARIABLE_MAPS_TAS_TREND=${VARIABLE_MAPS_DIR}/${VAR}-maps-global-tas-trend_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.nc
VARIABLE_MAPS_TIME_VERTICAL_PLOT=${VARIABLE_MAPS_DIR}/${VAR}-maps-time-trend-vertical-mean_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}
VARIABLE_MAPS_TIME_ZONAL_PLOT=${VARIABLE_MAPS_DIR}/${VAR}-maps-time-trend-zonal-mean_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}
VARIABLE_MAPS_TAS_VERTICAL_PLOT=${VARIABLE_MAPS_DIR}/${VAR}-maps-global-tas-trend-vertical-mean_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}
VARIABLE_MAPS_TAS_ZONAL_PLOT=${VARIABLE_MAPS_DIR}/${VAR}-maps-global-tas-trend-zonal-mean_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}

CLIMATOLOGY_FILE=${DEDRIFTED_VARIABLE_DIR}/${VAR}-clim_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
CLIMATOLOGY_MAPS_FILE=${VARIABLE_MAPS_DIR}/${VAR}-maps-clim_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc

OHC_METRICS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/${METRIC}/${RUN}
OHC_METRICS_FILE=${OHC_METRICS_DIR}/${METRIC}_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
OHC_METRICS_PLOT=${OHC_METRICS_DIR}/${METRIC}_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.${FIG_TYPE}

OHC_MAPS_DIR=${MY_CMIP5_DIR}/${ORGANISATION}/${MODEL}/${EXPERIMENT}/yr/ocean/ohc-maps/${RUN}
OHC_MAPS_FILE=${OHC_MAPS_DIR}/ohc-maps_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_all.nc
OHC_MAPS_PLOT=${OHC_MAPS_DIR}/ohc-maps_Oyr_${MODEL}_${EXPERIMENT}_${RUN}_${START_DATE}_${END_DATE}.${FIG_TYPE}


# De-drift

${DRIFT_COEFFICIENTS} :
	mkdir -p ${CONTROL_DIR} 
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_drift_coefficients.py ${CONTROL_FILES} $@ --var ${LONG_NAME} --annual

${DEDRIFTED_VARIABLE_DIR} : ${DRIFT_COEFFICIENTS}
	mkdir -p $@
	${PYTHON} ${DATA_SCRIPT_DIR}/remove_drift.py ${VARIABLE_FILES} ${LONG_NAME} $< $@/ --annual 
        #--no_parent_check

# Core data

${CLIMATOLOGY_FILE} : ${DEDRIFTED_VARIABLE_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_climatology.py ${DEDRIFTED_VARIABLE_FILES} ${LONG_NAME} $@

# Variable maps

${VARIABLE_MAPS_FILE} : ${CLIMATOLOGY_FILE}
	mkdir -p ${VARIABLE_MAPS_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_ocean_maps.py ${DEDRIFTED_VARIABLE_FILES} ${LONG_NAME} $@ --climatology_file $<
        #--chunk x --basin_file ${BASIN_FILE} --depth_file ${DEPTH_FILE}

${CLIMATOLOGY_MAPS_FILE} : ${CLIMATOLOGY_FILE}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_ocean_maps.py $< ${LONG_NAME} $@ 
        # --basin_file ${BASIN_FILE}  --depth_file ${DEPTH_FILE}

${VARIABLE_MAPS_TIME_TREND} : ${VARIABLE_MAPS_FILE}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_trend.py $< $@ --time_bounds ${START_DATE} ${END_DATE}

${VARIABLE_MAPS_TIME_VERTICAL_PLOT} : ${VARIABLE_MAPS_TIME_TREND}
	${PYTHON} ${VIS_SCRIPT_DIR}/plot_ocean_trend.py $< ${LONG_NAME} vertical_mean $@ --scale_factor ${SCALE_FACTOR} --vm_tick_scale 4 1 2 2 6 --palette ${PALETTE} --vm_ticks ${VM_TICK_MAX} ${VM_TICK_STEP}

${VARIABLE_MAPS_TIME_ZONAL_PLOT} : ${VARIABLE_MAPS_TIME_TREND} ${CLIMATOLOGY_MAPS_FILE}
	${PYTHON} ${VIS_SCRIPT_DIR}/plot_ocean_trend.py $< ${LONG_NAME} zonal_mean $@ --scale_factor ${SCALE_FACTOR} --palette ${PALETTE} --climatology_file $(word 2,$^) --zm_ticks ${ZM_TICK_MAX} ${ZM_TICK_STEP}

# Trends against global mean temperature

${GLOBAL_MEAN_TAS_FILE} :  
	mkdir -p ${GLOBAL_MEAN_TAS_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py ${TAS_FILE} air_temperature mean $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${VARIABLE_MAPS_TAS_TREND} : ${VARIABLE_MAPS_FILE} ${GLOBAL_MEAN_TAS_FILE} 
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_trend.py $< $@ --time_bounds ${START_DATE} ${END_DATE} --xaxis $(word 2,$^) air_temperature

${VARIABLE_MAPS_TAS_VERTICAL_PLOT} : ${VARIABLE_MAPS_TAS_TREND}
	${PYTHON} ${VIS_SCRIPT_DIR}/plot_ocean_trend.py $< ${LONG_NAME} vertical_mean $@  --vm_ticks ${VM_TICK_MAX} ${VM_TICK_STEP} --vm_tick_scale 4 1 2 2 6 --palette ${PALETTE} 

${VARIABLE_MAPS_TAS_ZONAL_PLOT} : ${VARIABLE_MAPS_TAS_TREND} ${CLIMATOLOGY_MAPS_FILE}
	${PYTHON} ${VIS_SCRIPT_DIR}/plot_ocean_trend.py $< ${LONG_NAME} zonal_mean $@ --palette ${PALETTE} --climatology_file $(word 2,$^) --zm_ticks ${ZM_TICK_MAX} ${ZM_TICK_STEP}

## Use ocean_summary_ensembles.sh if more than one run
## Use plot_trend_comparison.sh to compare GHG to AA
## Use plot_ocean_trend_ensemble.sh to plot same basin for entire ensemble

# Global indicators

${PE_DIR} :
	mkdir -p $@
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_pe.py ${PR_FILE} precipitation_flux ${EVSPSBL_DIR} water_evaporation_flux $@

${GLOBAL_ABS_PE_FILE} :
	mkdir -p ${GLOBAL_PE_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py $(wildcard ${PE_DIR}/pe_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc) precipitation_minus_evaporation_flux mean-abs $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${GLOBAL_AMP_PE_FILE} :
	mkdir -p ${GLOBAL_PE_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py $(wildcard ${PE_DIR}/pe_Amon_${MODEL}_${EXPERIMENT}_${RUN}_*.nc) precipitation_minus_evaporation_flux amplification $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${GLOBAL_AMP_SOS_FILE} :  
	mkdir -p ${GLOBAL_AMP_SOS_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py ${SOS_FILE} sea_surface_salinity amplification $@ --area_file ${OCEAN_AREA_FILE} --smoothing annual

${SOS_CLIM_FILE} :
	mkdir -p ${GLOBAL_AMP_SOS_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_climatology.py ${SOS_FILE} sea_surface_salinity $@

${GLOBAL_MYAMP_SOS_FILE} : ${SOS_CLIM_FILE}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_my_salinity_amp.py ${SOS_FILE} sea_surface_salinity $< $@ --area_file ${OCEAN_AREA_FILE} --smoothing annual

${GLOBAL_MEAN_PR_FILE} :  
	mkdir -p ${GLOBAL_MEAN_PR_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py ${PR_FILE} precipitation_flux mean $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${GLOBAL_MEAN_EVSPSBL_FILE} :  
	mkdir -p ${GLOBAL_MEAN_EVSPSBL_DIR}
	${PYTHON} ${DATA_SCRIPT_DIR}/calc_global_metric.py ${EVSPSBL_FILE} water_evaporation_flux mean $@ --area_file ${ATMOS_AREA_FILE} --smoothing annual

${GLOBAL_INDICATORS_PLOT} : ${GLOBAL_MEAN_TAS_FILE} ${GLOBAL_AMP_SOS_FILE} ${GLOBAL_ABS_PE_FILE}
	echo $@

        ## e.g. python plot_global_indicators.py /g/data/r87/dbi599/drstree/CMIP5/GCM/IPSL/IPSL-CM5A-LR/*/yr/ocean/sos/*/sos-global-amp_Oyr_IPSL-CM5A-LR_*_*_*.nc /g/data/r87/dbi599/drstree/CMIP5/GCM/IPSL/IPSL-CM5A-LR/*/yr/*/*/*/*global-mean_Ayr_IPSL-CM5A-LR_*_*_*.nc /g/data/r87/dbi599/figures/global_indicators/global-indcators_yr_IPSL-CM5A-LR_historicalAll_r1i1_all.png --aa_physics 3 --ant_physics 2

{'fraction_non_alphanumeric': 0.18488318827301878, 'fraction_numerical': 0.004855703160787907, 'mean_word_length': 8.549868766404199, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '949177', 'n_tokens_mistral': 9914, 'n_tokens_neox': 9665, 'n_words': 837}