Skip to content
Snippets Groups Projects
Commit 28183052 authored by Paul Gierz's avatar Paul Gierz
Browse files

most of the cookiecutter, still need to check with Sven if it works

parent d2a61d7f
No related branches found
No related tags found
No related merge requests found
Showing
with 17208 additions and 0 deletions
147.906826 45.012042
-122.101815 45.087483
-120.740927 49.811575
-124.823589 54.333782
-132.867944 58.290713
-137.041331 59.865410
-139.007056 59.946164
170.070565 60.551817
166.864919 62.974428
163.780242 60.390310
161.239919 58.694482
158.881048 55.787349
156.945565 51.749664
155.554435 50.296097
153.497984 48.196501
151.320565 46.581427
-41.602823 -20.121131
-41.723790 -13.337820
-50.191532 -5.181696
-59.324597 2.247645
-65.675403 8.788694
-70.131048 8.304172
-72.671371 7.738896
-76.481855 6.689098
-77.147177 7.254374
-77.631048 7.981157
-78.039315 8.707941
-78.674395 9.192463
-79.369960 9.313594
-79.763105 9.071332
-80.035282 8.748318
-80.549395 8.586810
-81.123992 8.384926
-81.910282 8.627187
-82.666331 8.869448
-83.513105 9.757739
-84.269153 10.807537
-84.662298 12.826380
-85.327621 14.360700
-87.232863 14.845222
-88.382056 15.168237
-89.924395 16.016151
-91.738911 17.429341
-94.526210 17.267833
-97.006048 18.963661
-98.578629 21.224764
-99.122984 25.666218
-98.699597 29.946164
-96.401210 31.884253
-90.110887 33.580081
-83.094758 36.083445
-77.409274 40.686406
-72.570565 43.674293
-72.066532 48.196501
-67.651210 50.376851
-57.459677 49.973082
-49.606855 49.650067
-43.558468 49.650067
-37.752016 49.892328
-31.340726 50.053836
-25.413306 49.892328
-19.364919 49.407806
-15.292339 49.569314
-9.788306 49.488560
-4.889113 48.842530
-1.743952 47.792732
2.852823 46.662180
6.905242 47.146703
11.864919 47.954240
16.159274 47.227456
20.393145 45.370121
23.256048 44.562584
25.493952 42.866756
27.671371 38.909825
30.272177 38.748318
33.840726 39.071332
36.622984 38.829071
38.195565 37.375505
37.953629 34.872140
37.288306 32.853297
36.199597 31.076716
34.868952 30.753701
32.510081 29.865410
28.881048 28.734859
23.558468 24.697174
11.643145 17.671602
10.836694 6.123822
15.252016 -5.827725
16.885081 -11.884253
14.203629 -19.475101
10.816532 -18.829071
4.284274 -19.071332
-2.913306 -19.475101
-9.445565 -19.636608
-19.153226 -20.040377
-29.637097 -20.040377
-41.602823 -20.121131
59. 26.3
55.2016 24.0
72.7074 71.8275
72.9378 70.3655
41.6901 66.8202
40.5012 66.1886
ncFile='./raw_input_data/{{cookiecutter.input_fname}}';
fldName='{{cookiecutter.input_varname}}';
ncid=netcdf.open(ncFile,'nowrite');
fld_id= netcdf.inqVarID(ncid,fldName);
lon_id= netcdf.inqVarID(ncid,'lon');
lat_id= netcdf.inqVarID(ncid,'lat');
fld=netcdf.getVar(ncid,fld_id);
fld=fld';
lon=netcdf.getVar(ncid,lon_id);
lat=netcdf.getVar(ncid,lat_id);
%lon=-180:1/60:180; lon=lon';
%lat=-90:1/60:90; lat=lat';
if min(size(lon))==2
lon=lon(1,:);
lat=lat(2,:);
end
netcdf.close(ncid)
imagesc(lon,lat,fld)
set(gca,'ydir','normal')
[C h]=contour(lon,lat,fld,[0. 0.]);
%cst=C';
%for i=1:size(cst,1)
% if cst(i,1)==0
% ofs=cst(i,2);
% cst(i,:)=cst(i+ofs,:);
% end
%end
cst=C';
CST=[];
for i=1:size(cst,1)
if cst(i,1)==0 & cst(i,2)>180
ofs=cst(i,2)
CST=[CST; cst(i+1:i+ofs,:)];
end
end
save -ascii {{cookiecutter.mesh_name}}_cst.txt CST
exit;
%Set Input:
%TopoDir='/work/ollie/sharig/data/topography/'
TopoDir='./raw_input_data/'
%TopoFile='herold_etal_eocene_topo_1x1.nc'
TopoFile='{{cookiecutter.input_fname}}'
% Set Output:
SaveDir='./mg/topo/'
suffix='{{cookiecutter.mesh_name}}';
ncfile='{{cookiecutter.mesh_name}}_input_file_used_for_matlab_routine.nc'
ncid=netcdf.open([TopoDir,TopoFile],'nowrite');
if ~exist('{{cookiecutter.input_varname}}','var')
varid_z = netcdf.inqVarID(ncid,'{{cookiecutter.input_varname}}');
%lon/lat
varid_ln = netcdf.inqVarID(ncid,'lon'); % uncomment if file contains
varid_lt = netcdf.inqVarID(ncid,'lat');
t=netcdf.getVar(ncid,varid_z);
t=t';
ln=netcdf.getVar(ncid,varid_ln);
lt=netcdf.getVar(ncid,varid_lt);
%ln=-180:1/60:180; ln=ln'; %define lon/lat as file did not contain it
%lt=-90:1/60:90; lt=lt';
end
netcdf.close(ncid)
lon=zeros(size(ln));
lat=lt;
topo=zeros(size(t));
if min(ln)>=0
ind=find(ln>=180.0);
len=length(ind);
topo(:,1:len)=t(:,ind);
lon(1:len)=ln(ind)-360.0;
ind=find(ln<180.0);
topo(:,len+1:end)=t(:,ind);
lon(len+1:end)=ln(ind);
else
lon=ln;
topo=t;
end
meshType='global'
% Options for meshType: global
if strcmp(meshType,'global')
LonMin=-180.0
LonMax= 180.0
LatMin=-90.0
LatMax= 90.0
end
tp=topo;
imagesc(lon,lat,tp)
set(gca,'ydir','normal');
title('This figure schould NOT be upside down')
ix1=1;
ix2=length(lon);
iy1=1;
iy2=length(lat);
write_netcdf_output=1
if write_netcdf_output
disp('Writing netcdf output')
ncid=netcdf.create([SaveDir,ncfile], 'clobber');
vid=netcdf.getConstant('NC_GLOBAL');
netcdf.putAtt(ncid,vid,'title','{{cookiecutter.mesh_name}} TOPOGRAPHY');
dimId_ax = netcdf.defDim(ncid,'nax',2);
dimId_lon = netcdf.defDim(ncid,'DimLon',ix2-ix1+1);
dimId_lat = netcdf.defDim(ncid,'DimLat',iy2-iy1+1);
varId_lon = netcdf.defVar(ncid,'lon','NC_FLOAT',[dimId_ax dimId_lon]);
varId_lon360 = netcdf.defVar(ncid,'lon360','NC_FLOAT',[dimId_ax dimId_lon]);
varId_lat = netcdf.defVar(ncid,'lat','NC_FLOAT',[dimId_ax dimId_lat]);
varId_topo = netcdf.defVar(ncid,'topo','NC_FLOAT',[dimId_lon dimId_lat]);
netcdf.putAtt(ncid,varId_topo,'field','topography value [m]');
netcdf.putAtt(ncid,varId_topo,'positions','lat, product; lon, product');
netcdf.endDef(ncid)
lon360 = lon;
ind=find(lon360<0);
lon360(ind)=lon360(ind)+360;
netcdf.putVar(ncid,varId_lon,[lon'; zeros(1,length(lon))])
netcdf.putVar(ncid,varId_lon360,[lon360'; zeros(1,length(lon))])
netcdf.putVar(ncid,varId_lat,[zeros(1,length(lat)); lat'])
netcdf.putVar(ncid,varId_topo,tp')
netcdf.close(ncid)
end
%disp('if you want to write TRIANGLE INPUT, please enter dbcont')
%keyboard
%disp('CAUTION: GRADIENT NOT COMPUTED')
% calculate topography gradient
[tpx tpy]=gradient(tp);
tpxy=sqrt(tpx.^2+tpy.^2); % absolute value of the gradient
tpxy=tpxy/max(max(tpxy)); % normalise to 1
fid=fopen([SaveDir,'lon_',suffix,'.bin32'],'w');
count = fwrite(fid,lon,'float32')
fclose(fid);
fid=fopen([SaveDir,'lat_',suffix,'.bin32'],'w');
count = fwrite(fid,lat,'float32')
fclose(fid);
%tp=tp'; % check orientation!
tp=-tp'; % check orientation!
fid=fopen([SaveDir,'topog_',suffix,'.bin32'],'w');
count = fwrite(fid,tp,'float32')
fclose(fid);
tpxy=tpxy';
fid=fopen([SaveDir,'topog_grad_',suffix,'.bin32'],'w');
count = fwrite(fid,tpxy,'float32')
fclose(fid);
exit;
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This script determines array sizes to be used in ``triangle_refine_global.c``
Dr. Paul Gierz, Jan 2020
"""
import argparse
import pathlib
# TODO: Add export functionality as module
def parse_arguments():
parser = argparse.ArgumentParser(
description="Determines sizes to use in triangle_refine_global.c",
epilog="Dr. Paul Gierz, 2020",
)
parser.add_argument(
"input_dir",
help="The directory where lat, lon, topog, and topog_grad.bin32 files can be found",
)
return parser.parse_args()
def print_topo_info(topo_path):
print(80*"=")
print("Determining sizes of all bin32 files in:", topo_path)
for f in topo_path.glob("*bin32"):
print("* ", f)
with open(f, "rb") as fbin:
contents = fbin.read()
# Subtract 4 from the length...?
# TODO: Figure out why!
print(" ", len(contents)-4)
print(80*"=")
def main():
args = parse_arguments()
topo_path = pathlib.Path(args.input_dir).resolve()
print_topo_info(topo_path)
if __name__ == "__main__":
main()
# -*- last line -*-
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Bootstrap script to create a new mesh based on the CORE 2 Resolution.
Dr. Paul Gierz, Jan 2020
"""
import os
import shutil
if __name__ == "__main__":
print(80*"=")
print("Starting generation of a mesh: {{cookiecutter.mesh_name}}.")
print(40*"- ")
print("Gathering input data:")
shutil.copyfile("{{cookiecutter.input_fpath}}", "./raw_input_data/{{cookiecutter.input_fname}}")
print(40*"- ")
print("* MATLAB Part:")
os.system("matlab.sh -s -S\"--mem=36000\" -M\"-nodisplay -r run('mg_topo_prep_triangle_input.m')\"")
os.system("matlab.sh -s -S\"--mem=36000\" -M\"-nodisplay -r run('mg_coastline.m')\"")
os.rename("{{cookiecutter.mesh_name}}_cst.txt", "mesh_CORE2_{{cookiecutter.mesh_name}}/{{cookiecutter.mesh_name}}_cst.txt")
# TODO: Get count from the other python script and write it somewhere
# TODO: C reads count from the file just written...
print(40*"- ")
print("* Triangle Part:")
os.system("sbatch -W run_triangle.sh")
print("Finished!")
print("You should now inspect your mesh!")
print(80*"=")
#!/bin/bash
#SBATCH -c 18 --time=12:00:00 -p smp
#Xsrun I know what I am doing
cd {{cookiecutter.project_path}}/FESOM2_Mesh_Generation_{{cookiecutter.mesh_name}}/mesh_CORE2_{{cookiecutter.mesh_name}}
make clean
make basic
make refine
module load intel.compiler
make relax
{
"project_path": "/work/ollie/pgierz/PalModII/",
"mesh_name": "EXAMPLE",
"input_varname": "topo",
"input_fpath": "/work/ollie/pgierz/PalModII/FESOM2_MIS3_Mesh_Generation/raw_input_data/reconstruction_a1_0.25_degree_42.5kaBP.nc",
"input_fname": "{{ cookiecutter.input_fpath.split('/')[-1] }}"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment