Skip to content

Commit

Permalink
Merge pull request #1 from nickywright/master
Browse files Browse the repository at this point in the history
update relationship for GlobSed and latest agegrid
  • Loading branch information
nickywright authored Aug 30, 2022
2 parents dd372bb + b7eef06 commit d9be942
Show file tree
Hide file tree
Showing 13 changed files with 97,707 additions and 61,918 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@ ENV/

# mypy
.mypy_cache/
python_notebooks_and_input_data_archive/.DS_Store
.DS_Store
63 changes: 40 additions & 23 deletions 01_generate_distance_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import os, shutil
import sys

""" This script creates grids (netcdfs) of the mean distance to passive margins through time
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
""" ---------- Part 1 of the predicting-sediment-thickness workflow -----------
This script creates grids (netcdfs) of the mean distance to passive margins through time
Requirements & Inputs:
- Python
Expand All @@ -18,46 +19,62 @@
- directory named 'distances_1d', with mean distance grids (in metres) through time.
2020-02-14: Added comments, removed hardcoded names (for rotation file, etc) from definitions
2022-08-29: Added more comments (NW)
"""

# ----- set directories and filenames

output_dir = 'distances_1d'
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# ------------------------------------------
# --- Set paths and various parameters
# ------------------------------------------

output_base_dir = '.'

# ------------------------------------------
# --- input files
proximity_features_files = [
'input_data/Global_EarthByte_GeeK07_COBLineSegments_2016_v4.gpmlz', # this is included in this repository
]

# --- lcoation of files on your computer
data_dir = '/home/michael/workspace/predicting-sediment-thickness/Muller_etal_2016_AREPS'

# --- agegrids
age_grid_dir = '%s/Muller_etal_2016_AREPS_Agegrids/Muller_etal_2016_AREPS_Agegrids_v1.17/Muller_etal_2016_AREPS_v1.17_netCDF' % data_dir # change folder name if needed
age_grid_filename = 'Muller_etal_2016_AREPS_v1.17_AgeGrid-' # everything before 'time'
age_grid_filename_ext = 'nc' # generally 'nc', but sometimes is 'grd'. Do not include the period
# --- lcoation of gplates files on your computer
# DON'T FORGET TO UPDATE ocean_basin_proximity.py!
# --- agegrids. Can be found here: https://www.earthbyte.org/gplates-2-3-software-and-data-sets/
agegrid_dir = '/Users/nickywright/Data/Age/Muller2019-Young2019-Cao2020_Agegrids/Muller2019-Young2019-Cao2020_netCDF' # change folder name if needed
agegrid_filename = 'Muller2019-Young2019-Cao2020_AgeGrid-' # everything before 'time'
agegrid_filename_ext = 'nc' # generally 'nc', but sometimes is 'grd'. Do not include the period

# --- topologies and other files
topology_dir = '%s' % data_dir
data_dir = '/Applications/GPlates_2.3.0/GeoData/FeatureCollections/'
rotation_filenames = [
'%s/Muller_etal_2016_AREPS_Supplement/Muller_etal_2016_AREPS_Supplement_v1.17/Global_EarthByte_230-0Ma_GK07_AREPS.rot' % topology_dir,
]
topology_filenames = [
'%s/Muller_etal_2016_AREPS_Supplement/Muller_etal_2016_AREPS_Supplement_v1.17/Global_EarthByte_230-0Ma_GK07_AREPS_PlateBoundaries.gpml' % topology_dir,
'%s/Muller_etal_2016_AREPS_Supplement/Muller_etal_2016_AREPS_Supplement_v1.17/Global_EarthByte_230-0Ma_GK07_AREPS_Topology_BuildingBlocks.gpml' % topology_dir,
]
'%s/Rotations/Muller2019-Young2019-Cao2020_CombinedRotations.rot' % data_dir]

topology_filenames = [
'%s/DynamicPolygons/Muller2019-Young2019-Cao2020_PlateBoundaries.gpmlz' % data_dir,
'%s/DeformingLithosphere/Muller2019-Young2019-Cao2020_ActiveDeformation.gpmlz' % data_dir]

# ------------------------------------------
# --- set times and spacing
grid_spacing = 1.0
grid_spacing = 1

min_time = 0
max_time = 230
max_time = 250
time_step = 1

proximity_threshold_kms = 3000

output_dir = '%s/distances_%sd' % (output_base_dir, grid_spacing)

num_cpus = multiprocessing.cpu_count() - 1 # number of cpus to use. Reduce if required!

# ------------------------------------------
# END USER INPUT
# ------------------------------------------

# -----
# make needed directories
if not os.path.exists(output_base_dir):
os.makedirs(output_base_dir)


if not os.path.exists(output_dir):
print('%s does not exist, creating now... ' % output_dir)
os.mkdir(output_dir)
Expand All @@ -77,7 +94,7 @@ def generate_distance_grid(time):
command_line.extend('{0}'.format(topology_filename) for topology_filename in topology_filenames)
command_line.extend([
'-g',
'{0}/{1}{2}.{3}'.format(age_grid_dir, age_grid_filename, time, age_grid_filename_ext),
'{0}/{1}{2}.{3}'.format(agegrid_dir, agegrid_filename, time, agegrid_filename_ext),
'-y {0}'.format(time),
'-n',
# Use all feature types in proximity file (according to Dietmar)...
Expand Down Expand Up @@ -161,7 +178,7 @@ def low_priority():
if __name__ == '__main__':

try:
num_cpus = multiprocessing.cpu_count()
num_cpus = num_cpus
except NotImplementedError:
num_cpus = 1

Expand Down
75 changes: 47 additions & 28 deletions 02_generate_predicted_sedimentation_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import os, shutil
import sys

""" This script creates grids (netcdfs) of sediment thickness and sediment rate through time
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
""" ---------- Part 2 of the prediciting-sediment-thickness workflow ----------
This script creates grids (netcdfs) of sediment thickness and sediment rate through time
Requirements amd Inputs:
- Python
Expand All @@ -25,31 +27,42 @@
subfolders of sediment thickness and sediment rate grids through time.
2020-02-25: Added comments, created folders within the script itself
2022-08-26: Update parameters for GlobSed and latest agegrids. Modify dirs to be consistent with pt1
"""

# ----- set directories and filenames
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# ------------------------------------------
# --- Set paths and various parameters
# ------------------------------------------

data_dir = '/home/michael/workspace/predicting-sediment-thickness/Muller_etal_2016_AREPS'
age_grid_dir = '%s/Muller_etal_2016_AREPS_Agegrids/Muller_etal_2016_AREPS_Agegrids_v1.17/Muller_etal_2016_AREPS_v1.17_netCDF' % data_dir
output_base_dir = '.'

agegrid_filename = 'Muller_etal_2016_AREPS_v1.17_AgeGrid-' # everything before 'time'
agegrid_filename_ext = 'nc'
# --- distance grids (from part 1)
distance_grid_dir = '%s/distances_1d' % output_base_dir
distance_base_name = 'mean_distance_1d'


distance_grid_dir = 'distances_1d'
distance_base_name = 'mean_distance_1.0d'

output_base_dir = '/home/michael/workspace/predicting-sediment-thickness'
# --- output directory name
sediment_output_sub_dir = 'sedimentation_output'

# --- agegrids
agegrid_dir = '/Users/nickywright/Data/Age/Muller2019-Young2019-Cao2020_Agegrids/Muller2019-Young2019-Cao2020_netCDF' # change folder name if needed
agegrid_filename = 'Muller2019-Young2019-Cao2020_AgeGrid-' # everything before 'time'
agegrid_filename_ext = 'nc' # generally 'nc', but sometimes is 'grd'. Do not include the period

# ------------------------------------------
# --- set times and spacing
grid_spacing = 0.2
grid_spacing = 0.1

min_time = 0
max_time = 230
max_time = 250
time_step = 1

# -----
num_cpus = multiprocessing.cpu_count() - 1 # number of cpus to use. Reduce if required!

# ------------------------------------------
# END USER INPUT
# ------------------------------------------

# check if the base output directory exists. If it doesn't, create it.
if not os.path.exists(output_base_dir + '/' + sediment_output_sub_dir):
print('%s does not exist, creating now... ' % (output_base_dir + '/' + sediment_output_sub_dir))
Expand Down Expand Up @@ -80,7 +93,7 @@ def generate_predicted_sedimentation_grid(
'-d',
'{0}/{1}_{2}.nc'.format(distance_grid_dir, distance_base_name, time),
'-g',
'{0}/{1}{2}.{3}'.format(age_grid_dir, agegrid_filename, time, agegrid_filename_ext),
'{0}/{1}{2}.{3}'.format(agegrid_dir, agegrid_filename, time, agegrid_filename_ext),
'-i',
str(grid_spacing),
'-w',
Expand Down Expand Up @@ -168,7 +181,7 @@ def low_priority():
if __name__ == '__main__':

try:
num_cpus = multiprocessing.cpu_count()
num_cpus = num_cpus
except NotImplementedError:
num_cpus = 1

Expand Down Expand Up @@ -217,17 +230,20 @@ def low_priority():
# print('Polynomial feature names:', regressor.named_steps['poly'].get_feature_names())
#
#

# updated for GlobSed and TRUNK agegrids
predict_sedimentation_script = 'predict_sedimentation_rate.py'
#scale_sedimentation_rate = 1.0 # Keep predicted rate in (cm/Ky).
scale_sedimentation_rate = 10.0 # Scale predicted rate (cm/Ky) to (m/My).
mean_age = 61.45090081
mean_distance = 1828.27150101
variance_age = 1970.24537854
variance_distance = 1213531.02057604
max_age = 206.88276672
mean_age = 61.17716597
mean_distance = 1835.10750592
variance_age = 1934.78513885
variance_distance = 1207587.8548734
max_age = 191.87276
max_distance = 3000.
age_distance_polynomial_coefficients = [
1.3757381318064446, -0.32271631, -0.10326943, 0.35609403, -0.17139341, 0. , -0.08800471, 0.04551093, -0.01790009, -0.47805069]
1.350082937086441, -0.26385415, -0.07516542, 0.39197707, -0.15475392,
0. , -0.13196083, 0.02481208, -0. , -0.47570021]

output_dir = output_base_dir + '/' + sediment_output_sub_dir + '/predicted_rate'

Expand Down Expand Up @@ -280,16 +296,19 @@ def low_priority():
# print('Polynomial feature names:', regressor.named_steps['poly'].get_feature_names())
#
#

# updated for GlobSed and TRUNK agegrids (NW 20220826)
predict_sedimentation_script = 'predict_sediment_thickness.py'
scale_sedimentation_rate = None # No scaling - we're predicting sediment thickness (not rate).
mean_age = 61.45473054
mean_distance = 1828.56033082
variance_age = 1969.66845378
variance_distance = 1213348.68588578
max_age = 206.88276672
mean_age = 61.18406823
mean_distance = 1835.28118479
variance_age = 1934.6999014
variance_distance = 1207521.8995806
max_age = 191.87276
max_distance = 3000.
age_distance_polynomial_coefficients = [
5.458863944268268, 0.45435012, -0.08694418, -0.26274333, -0.11545711, 0.00911016, 0.08546976, 0.02393832, 0. , -0.40411004]
5.441401190368497, 0.46893096, -0.07320928, -0.24077496, -0.10840657,
0.00381672, 0.06831728, 0.01179914, 0.01158149, -0.39880562]

output_dir = output_base_dir + '/' + sediment_output_sub_dir + '/predicted_thickness'

Expand Down
4 changes: 2 additions & 2 deletions ocean_basin_proximity.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import subprocess
import sys

data_dir = '/home/michael/workspace/predicting-sediment-thickness/Muller_etal_2016_AREPS/Muller_etal_2016_AREPS_Supplement/Muller_etal_2016_AREPS_Supplement_v1.17'
coastline_filename = '%s/Global_EarthByte_230-0Ma_GK07_AREPS_Coastlines.gpml' % data_dir
data_dir = '/Applications/GPlates_2.3.0/GeoData/FeatureCollections/'
coastline_filename = '%s/Coastlines/Global_EarthByte_GPlates_PresentDay_Coastlines.gpmlz' % data_dir

USE_SHORTEST_DISTANCE = True

Expand Down
Loading

0 comments on commit d9be942

Please sign in to comment.