-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkelp2grid_kit4.py
More file actions
93 lines (61 loc) · 1.78 KB
/
kelp2grid_kit4.py
File metadata and controls
93 lines (61 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# -*- coding: utf-8 -*-
"""
Front Matter
=============
Created on
Author: Mitchell O'Flaherty-Sproul
Requirements
===================================
Absolutely Necessary:
* Numpy
* SciPy
* Matplotlib
Optional, but recommended:
Functions
=========
"""
#load modules
import numpy as np
import scipy.io as sio
import matplotlib.pyplot as plt
from math import pi
from datatools import *
from gridtools import *
from misctools import *
import scipy as sp
import matplotlib as mpl
np.set_printoptions(precision=8,suppress=True,threshold=sys.maxsize)
import sys
data = loadnc('runs/kit4/kit4_45days_3/output/')
data =ncdatasort(data)
kelp=np.genfromtxt('kelplocations.dat')
maxdepth=30
mindepth=5
savepath='figures/png/kit4/misc/'
if not os.path.exists(savepath): os.makedirs(savepath)
host=data['trigrid'].get_trifinder().__call__(kelp[:,0],kelp[:,1])
#host=np.unique(host)
#host=host[host !=-1]
newhost=host
newhost=np.unique(newhost)
newhost=newhost[newhost !=-1]
host_lt_depth=np.where((data['uvh'][newhost]<=maxdepth) & (data['uvh'][newhost]>=mindepth))[0]
newhostbool=np.zeros(shape=newhost.shape,dtype=bool)
newhostbool[host_lt_depth]=True
newhost=newhost[host_lt_depth.flatten()]
tempdic={}
tempdic['kelp_elements']=newhost
#sio.savemat('kelp_elements_kit4.mat',mdict=tempdic)
#np.savetxt('kelpnodes_kit4.dat',newhost+1,fmt='%i')
drag=np.zeros([newhost.shape[0],])+0.018
depth=np.zeros([newhost.shape[0],])+40
fvcom_savecage('data/cage_files/kit4_cage_'+("%d"%mindepth)+'m_'+("%d"%maxdepth)+'m.dat',newhost+1,drag,depth)
trihost=np.zeros([data['uvnodell'].shape[0],])
trihost[newhost]=1
plt.close()
plt.tripcolor(data['trigrid'],trihost)
plt.colorbar()
plt.grid()
plt.title('Locations with kelp')
plt.savefig(savepath + 'kelp_host_locations.png',dpi=1200)
plt.close()