coxmunk 1.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- coxmunk/__init__.py +7 -0
- coxmunk/cox_munk_validate.py +87 -0
- coxmunk/coxmunk.py +745 -0
- coxmunk/test.py +49 -0
- coxmunk/visu.py +235 -0
- coxmunk/wind.py +282 -0
- coxmunk-1.2.1.dist-info/METADATA +337 -0
- coxmunk-1.2.1.dist-info/RECORD +12 -0
- coxmunk-1.2.1.dist-info/WHEEL +5 -0
- coxmunk-1.2.1.dist-info/entry_points.txt +2 -0
- coxmunk-1.2.1.dist-info/licenses/LICENSE +21 -0
- coxmunk-1.2.1.dist-info/top_level.txt +1 -0
coxmunk/__init__.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import coxmunk
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
import cmocean as cm
|
|
6
|
+
|
|
7
|
+
import coxmunk.coxmunk as coxmunk
|
|
8
|
+
from coxmunk.visu import plot as uplot
|
|
9
|
+
|
|
10
|
+
wind = 14.5
|
|
11
|
+
wind_azi = 75
|
|
12
|
+
stats =['cm_iso','cm_dir','bh2006']
|
|
13
|
+
stat=stats[2]
|
|
14
|
+
shadow=True
|
|
15
|
+
refrac_index=1.334
|
|
16
|
+
|
|
17
|
+
sza = 39
|
|
18
|
+
vza = np.linspace(0,80,81)
|
|
19
|
+
azi = np.linspace(0,360,181)
|
|
20
|
+
Nvza,Nazi =len(vza),len(azi)
|
|
21
|
+
|
|
22
|
+
data=np.zeros((Nazi,Nvza,4))
|
|
23
|
+
for i in range(Nvza):
|
|
24
|
+
for j in range(Nazi):
|
|
25
|
+
data[j,i,:]=coxmunk.sunglint(
|
|
26
|
+
sza,vza[i],azi[j],m=refrac_index).sunglint(
|
|
27
|
+
wind, wind_azi, stats=stat, shadow=shadow)
|
|
28
|
+
|
|
29
|
+
fig, axs = plt.subplots(nrows=2,ncols=2, subplot_kw=dict(projection='polar'),figsize=(15, 13))
|
|
30
|
+
axs=axs.ravel()
|
|
31
|
+
axs[0].scatter([0],[sza],marker='*',facecolor ='orange',alpha=0.6,s=1000)
|
|
32
|
+
uplot().label_polplot(axs[0],yticks=[20., 40., 60.,80.], ylabels=[r'$20^{\circ}$', r'$40^{\circ}$', r'$60^{\circ}$',''])
|
|
33
|
+
|
|
34
|
+
axs[0].arrow(wind_azi*np.pi/180, 0, 0,np.max(vza)*max(3,min(16,wind))/22, alpha = 0.5, width = 0.05,head_width=0.25,head_length=15,
|
|
35
|
+
edgecolor = 'black', facecolor = 'green', lw = 1.2)
|
|
36
|
+
axs[0].set_title('Sun and wind directions', pad=30)
|
|
37
|
+
|
|
38
|
+
for i,title in enumerate(('I','Q','U')):
|
|
39
|
+
if title=='I':
|
|
40
|
+
cmap = plt.cm.gist_stern_r
|
|
41
|
+
else:
|
|
42
|
+
cmap = cm.tools.crop_by_percent(cm.cm.balance, 20, which='both', N=None)
|
|
43
|
+
uplot().add_polplot(axs[i+1], vza, azi, data[...,i+1].T, title=title, cmap=cmap)
|
|
44
|
+
# I=data[...,0].T
|
|
45
|
+
# Q=data[...,1].T
|
|
46
|
+
# U=data[...,2].T
|
|
47
|
+
# DOP = np.sqrt(Q**2+U**2)#/I
|
|
48
|
+
# uplot().add_polplot(axs[3], vza, azi, DOP, title='DOP', cmap=cmap)
|
|
49
|
+
plt.suptitle(r'Wind speed: {:.1f} m/s; direction: {:.1f} deg.'.format(wind,wind_azi))
|
|
50
|
+
plt.tight_layout(rect=[0.0, 0.0, 0.99, 0.95])
|
|
51
|
+
|
|
52
|
+
# plot Pdist
|
|
53
|
+
def Pdist_(ws,eta,xi,stats='bh2006'):
|
|
54
|
+
if stats == 'cm_dir': # historical values from directional COX MUNK
|
|
55
|
+
s_cr2 = 0.003 + 1.92e-3 * ws
|
|
56
|
+
s_up2 = 3.16e-3 * ws
|
|
57
|
+
s_cr = np.sqrt(s_cr2)
|
|
58
|
+
s_up = np.sqrt(s_up2)
|
|
59
|
+
c21 = 0.01 - 8.6e-3 * ws
|
|
60
|
+
c03 = 0.04 - 33.e-3 * ws
|
|
61
|
+
c40 = 0.40
|
|
62
|
+
c22 = 0.12
|
|
63
|
+
c04 = 0.23
|
|
64
|
+
elif stats == 'bh2006': # from Breon Henriot 2006 JGR
|
|
65
|
+
s_cr2 = 3e-3 + 1.85e-3 * ws
|
|
66
|
+
s_up2 = 1e-3 + 3.16e-3 * ws
|
|
67
|
+
s_cr = np.sqrt(s_cr2)
|
|
68
|
+
s_up = np.sqrt(s_up2)
|
|
69
|
+
c21 = -9e-4 * ws ** 2
|
|
70
|
+
c03 = -0.45 / (1 + np.exp(7. - ws))
|
|
71
|
+
c40 = 0.30
|
|
72
|
+
c22 = 0.12
|
|
73
|
+
c04 = 0.4
|
|
74
|
+
return np.exp(-5e-1 * (xi ** 2 + eta ** 2)) / (2. * np.pi * s_cr * s_up) * \
|
|
75
|
+
(1. -
|
|
76
|
+
c21 * (xi ** 2 - 1.) * eta / 2. -
|
|
77
|
+
c03 * (eta ** 3 - 3. * eta) / 6. +
|
|
78
|
+
c40 * (xi ** 4 - 6. * eta ** 2 + 3.) / 24. +
|
|
79
|
+
c04 * (eta ** 4 - 6. * eta ** 2 + 3.) / 24. +
|
|
80
|
+
c22 * (xi ** 2 - 1.) * (eta ** 2 - 1.) / 4.)
|
|
81
|
+
|
|
82
|
+
plt.figure()
|
|
83
|
+
ws=10
|
|
84
|
+
xi=np.linspace(0,10,100)
|
|
85
|
+
eta=1e-2
|
|
86
|
+
plt.plot(xi,Pdist_(ws,eta,xi))
|
|
87
|
+
|