README Baatsen et al. (2015) Palaeogeography Reconstruction

Workflow for 38Ma Reconstruction using Hinsbergen plate-tectonic model in GPlates:
The latest version can be downloaded at www.earthbyte.org, here version 1.4 was used.
For questions, contact me at: m.l.j.baatsen@uu.nl

Before you start, create 2 directories: one containing all the 'source' files and the
other to save 'adjusted' files. The former contains files that are downloaded or provided
for use mostly in GPlates and the latter will be used to store the adjusted files for a
specific time frame and the Matlab script 'Reconstruction_steps', which will create the
final geometry netcdf file. Additionally, it contains a sub folder 'Geometries' to store
the outlines of all of the masks and convert them into a gridded NetCDF file using the 3
scripts provided.


1. Export Masks as Shapefiles

In a first attempt, steps 1 and 2 can be omitted, as an example of the gridded mask files
is already provided. If desired, these can be can be created using the procedure below.

Open following features in GPlates:
	- Rotation file (vanHinsbergen_master.rot)
	  The most recent version of this file can be downloaded at: www.geologist.nl
	  You can also use e.g. the Seton 2012 reconstruction, available at: www.earthbyte.org
	  in combination with your own set of outlines.
	- Outlines: Coastlines.gpml, ContinentalShelves_exp.gpml, ShallowSeas.gpml.
	  The Coastlines shape file (renamed) can also be downloaded from www.geologist.nl
	  (under 'Reconstructions', 'Shape files', 'Coastlines_Seton_etal_2012.gpml').
	- General adjustment masks: AdjMasks.gpml, containing outlines that cover the Andes,
	  Western Sierra, Greenland, Middle East, Turkey, Kaukasians, Arabia, African Rift, 
	  Ninety East Ridge and the Tasman Rise.
	- Specific adjustment masks for 38Ma topography: TopoMasks38.gpml, this file contains
	  outlines for the Himalayas, Tibet and Eastern Asia.
	- Specific adjustment masks for 38Ma bathymetry: Oceans38Ma.gpml, Seas38Ma.gpml, 
	  Shallow38Ma and the additional landmask Land38Ma_c.gpml.
	  
All of the outlines are connected to the reconstruction framework, so change the time to
38Ma to put them into their 38Ma configuration. Now export all of the masks at once as
shapefiles by doing the following;
	- Make sure all of the outlines are set to visible i.e. they have a little eye checked
	  in the Layers dialog.
	- Choose 'Reconstruction', 'Export...' from the general GPlates menu (top of screen);
	- Select 'Export Single Snapshot Instant' and click 'Use Main Window Type', or just
	  enter '38' into the 'Time' box.
	- Change 'Target Directory' into the 'Geometries' subfolder within 'Adjusted Files'.
	- Click 'Add Export', 'Reconstructed Geometries' and choose 'Shapefiles (*.shp)'.
	- Make sure that 'Export to a single file' is unchecked and 'Export to multiple files'
	  (as well as 'Separate output directory') is checked. 'Wrap polyline and polygon
	  geometries to the dateline' should also be checked to avoid horizontal lines.
	- Leave the export name as it is (since it will be stored in separate folders), apart
	  from changing '_%0.2fMa' to '_%0.0fMa'. This will give you the suffix '38Ma' instead
	  of '38.00Ma', which is unnecessary.
	- Click OK and wait for the export to finish (should take just seconds).


2. Convert The Masks into gridded NetCDF files

To be used by the script that builds up the actual geography reconstruction, the set of 
masks created needs to be converted into a gridded format. For this purpose, three simple
scripts are provided within the folder 'Geometries', called 'AdjMasks2grid.m',
'Boundaries2grid.m' and 'LOMask2grid.m', respectively. Before you start, make sure that 
this folder also has subfolders named 'Figures' and 'Files' that will be used as output
destinations by the scripts.

Start Matlab, navigate your workspace to the 'Geometries' folder and open the first script
'AdjMasks2grid.m'. At the start, you can change the reconstruction time and grid size but
it should work fine as it is for the example case. Running it will result in one pop-up
figure and the creation of a file called 'AdjMasks38.nc' that can be found in 'Files'.
You can check the output to see whether they contain the masks as they appeared in
GPlates. The same holds for the other 2 scripts, with the only complication caused by the
fact that these masks will use multiple input files. For instance, 'Boundaries2grid.m'
will use 'ShallowSeas', 'ContinentalShelves_exp' and 'Coastlines', and combine those into
one gridded mask. The set of input files is stated in the 'Names' variable and can be
changed if a different set of input fields is used. As some of the masks may have overlap,
make sure that they are in the right order to prevent them from obscuring each other.

In addition to 'AdjMasks2grid.m', now also run 'Boundaries2grid.m' and 'LOMask2grid.m', 
this may take a few minutes as some of the shapefiles are rather extensive. This should
provide you with 4 files in the 'Figures' folder and 3 in the 'Files' folder;
	- Figures: 'AdjMasks_gridded38.png', 'Boundaries_gridded38.png',
	  'LOMask_gridded38.png' and 'TopoMask_gridded38Ma.png';
	- Files: 'AdjMasks38.nc', 'Boundaries38.nc' and 'Masks38.nc'.


3. Create starting topography and bathymetry 
(Topo_38.00Ma.nc, TopoBR_38.00Ma.nc and SS_38.00Ma.nc).

The source files can be downloaded from NOAA; http://www.ngdc.noaa.gov/mgg/global.
You need both the ETOPO1 ice surface and bedrock topography, of which you should select
the cell-based variant in netcdf format. The file will come out as a .grd file but this
is no issue as it is processed properly by GPlates.

Open GPlates and open the appropriate rotation file (vanHinsbergen_master.rot or other).
Select 'File', 'Import', 'Import Raster' and select the downloaded netcdf/grd ETOPO1 file,
do this for both the ice surface and bedrock elevation (follow the dialog instructions).
Also open 'Coastlines.gpml' and 'ShallowSeas.gpml', set the time to 38Ma.
The topo file will not change yet, it needs to be coupled to a set of outlines. In the
'Layers' Panel, in the drop down menu of ETOPO1 click 'Add new connection' and select 
Coastlines. Similarly, connect the ETOPO1 bedrock data to Coastlines as well.

Similar to the Mask images, the adjusted ETOPO1 datasets can be exported but now as a
numerical raster. Select 'Reconstruction', 'Export', 'Use Main Window Time', 'Numerical 
Raster', 'NetCDF (*.nc)'. Change the pixel spacing to 0.1 Degrees and use Global Extents
(this should be the default). Change the Template to 'Topo_%0.2fMa, click OK, select the
right Target Directory and 'Export Snapshot'. Next, do the same for the bedrock topography 
but change the Template to 'TopoBR_%0.2fMa' and use the same Target Directory.
Finally, using the ETOPO1 dataset once more, make a reconstruction for the shallow ocean
regions. First remove the connection to Coastlines by clicking the '-' icon next to it and
connect it to ShallowSeas instead. Repeat the procedure to export this dataset as a netcdf
file with the Template 'SS_%0.2fMa'.


4. Reconstruct ocean floor agegrid (Age_38.00Ma.nc).

Download the Muller 2008 present day agegrid from: www.earthbyte.org, or another source.
('Resources', 'GPlates', 'GPlates [version] Software and Datasets', 'Rasters', 'Global 
Present Day Agegrid', 'Download - zip file');
As a .gpml file is already included in the download, you can open this as a regular
feature, only make sure that the according .nc file is in the same folder.
Fron the same website (same page), download the Seton 2012 static polygons.
Open the Static Polygons feature, together with the rotation file in GPlates.
Couple the Agegrid to the Static Polygons and change the time to 38Ma, then export the
dataset as a netcdf file similar to the ETOPO1 data with Template 'Age_%0.2fMa'.

When using the Seton_2012 reconstruction instead, you can simply download the ocean
agegrid for this specific time frame and rename it.


5. Ocean floor bathymetry.

Using the present day age grid allows one to use any reconstruction framework but leaves
gaps where subduction has taken place since the considered time frame. These can be filled
in with the Mueller 2008 bathymetry reconstruction, available at the EarthByte website
(ftp.earthbyte.org/earthbyte/agegrid/Palaeo/2008/Data).
Download the 'age_depth_bath_38.xyadb.bz2' file, unzip it and convert it into a netcdf
file containing only the palaeobathymetry data (consult the README.txt listed on top) and
save it as 'Mueller38Ma.nc' with your other source files.

Open the feature Globe.gpml and the adjusted rotation file Seton_rev701.rot. The latter is
adapted to reverse the movement of Africa (plate ID 701) in time to cancel out any mantle
movement that may differ with other reconstruction frameworks. Import the Mueller38Ma.nc 
file as a numerical raster and connect it to Globe (this is just a global mask connected
to Africa), then change the time to 38Ma and export the file as .nc with the Template
'Mueller_rev_%0.2fMa' and save it to the folder with source files.

Using GPlates again with Globe.gpml but the rotation file used in the above steps
(vanHinsbergen_master.rot), import the adjusted Mueller palaeobathymetry file. Connect 
Mueller_rev_38.00Ma to Globe.gpml and once more change the time to 38Ma, this will make it
compatible with the adjusted age grid. Change its name into: Mueller38Ma_cor.nc.


6. Antarctic Reconstruction (WilsonAR_38.00Ma.nc).

For the period around the Eocene-Oligocene Transition, a detailed reconstruction of the
Antarctic topography was presented in Wilson, 2012. The best estimate dataset is provided
with the paper in Palaeoceanography, Palaeoclimatology, Palaeoecology and was converted 
into a netcdf file called WilsonAR.nc.

In GPlates, open the features ContinentalShelves_exp.gpml and the rotation file.
Import WilsonAR.nc as a raster, connect it to ContinentalShelves_exp and set the time to
the considered time frame (38Ma). Export the dataset as a numerical raster, .nc file, set
the Template to 'WilsonAR_%0.2fMa' and choose the right Target directory.

For periods far from the EOT, present day topography will be corrected for isostatic 
rebound (using Topo and TopoBR) or another reconstruction can be used.


7. Files Overview.

All preparations should be done now; and you end up with 2 folders containing the files:
	1. Source Files: (d: downloaded, p: provided, c:created)
		vanHinsbergen_master.rot (d)
		Seton_rev701.rot (p)
		Coastlines.gpml (p)
		ContinentalShelves_exp.gpml (p)
		ShallowSeas.gpml (p)
		AdjMasks.gpml (p)
		Globe.gpml (p)
		
		Oceans38Ma.gpml (p)
		Seas38Ma.gpml (p)
		Shallow38Ma.gpml (p)
		TopoMasks38Ma.gpml (p)
		Land38Ma_c.gpml (p)
		
		ETOPO1_gmt4.grd (d)
		ETOPO1_Bed_c_gmt.grd (d)
		age_depth_bath_38.xyadb (d)
		WilsonAR.nc (p)
		Mueller_38Ma.nc (c)
		Mueller_rev_38.00Ma.nc (c)
	
	2. Adjusted Files:
		Age_38.00Ma.nc (c)
		Mueller38Ma_cor.nc (c)
		SS_38.00Ma.nc (c)
		Topo_38.00Ma.nc (c)
		TopoBR_38.00Ma.nc (c)
		WilsonAR_38.00Ma.nc (c)
		
		Folder 'Geometries' containing:
		AdjMasks (c)
		Coastlines (c)
		ContinentalShelves_exp (c)
		Figures (4 png images) (p/c)
		Files (3 .nc files) (p/c)
		Land38Ma (c)
		Oceans38Ma (c)
		Seas38Ma (c)
		Shallow38Ma (c)
		ShallowSeas (c)
		TopoMask38 (c)
		AdjMasks2grid.m (p)
		Boundaries2grid.m (p)
		LOMask2grid.m (p)
		
		Recostruction_steps.m (p)
		inpaintn.m (p)


8. Make the Final Reconstruction.

Starting from the set of files in the folder with data, the script Reconstruction_steps 
will create a global geography and save it as a netcdf gridded dataset. The output is a
set of .png images showing the different steps in the reconstruction and the Masks as they
are used. In addition, the reconstruction will be saved as both a .nc and .mat file (the 
latter is only for further use in Matlab); TopoBathy38.nc qnd TopoBathy38.mat. The former
is also adjusted to a coarser grid (0.5deg, but this can be changed) which suits the
final use (mostly scripts that create a set of initial files to run a GCM), it will be
saved as TopoBathyc38.nc.

The script itself is provided with comments on each of the specific steps. A number of 
parameters that can be changed are stated at the start, such as the output resolution, 
depth of the continental shelves, amount of sea level rise etc.
Further changes can be made to the effect of various Masks, also make sure that the extent
of fixed masks (such as the one for the Andes) agrees with your reconstruction when
changing the time or rotation frame. The same holds for corrections of specific shallow
regions (NER: Ninety East Ridge and TR: Tasman Rise).

Running the script will provide you with the following set of files:
	1. Images:
		Boundaries_gridded.png
		LOMask_gridded.png
		
		Step[1 through 10].png
		Step7adj.png
	
	2. Data Files:
		TopoBathy38.mat
		TopoBathy38.nc
		TopoBathyc38.nc
