Skip to content

Commit

Permalink
Merge pull request #9 from GEUS-SICE/dev
Browse files Browse the repository at this point in the history
pySICEv1.5
  • Loading branch information
BaptisteVandecrux authored Oct 19, 2021
2 parents 326fb13 + d8e2726 commit 8aa1fcb
Show file tree
Hide file tree
Showing 22 changed files with 617 additions and 2,171 deletions.
68 changes: 68 additions & 0 deletions bav_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,43 @@
months = mdates.MonthLocator() # every month
years_fmt = mdates.DateFormatter('%Y')

#%%
from math import radians, cos, sin, asin, sqrt
def haversine(lat1, lon1, lat2, lon2, to_radians=True, earth_radius=6371):
"""
slightly modified version: of http://stackoverflow.com/a/29546836/2901002
Calculate the great circle distance between two points
on the earth (specified in decimal degrees or in radians)
All (lat, lon) coordinates must have numeric dtypes and be of equal length.
"""
if to_radians:
lat1, lon1, lat2, lon2 = np.radians([lat1, lon1, lat2, lon2])

a = np.sin((lat2-lat1)/2.0)**2 + \
np.cos(lat1) * np.cos(lat2) * np.sin((lon2-lon1)/2.0)**2

return earth_radius * 2 * np.arcsin(np.sqrt(a))

# %%
def stat_title(x,y,ax):
ind = np.logical_and(pd.notnull(x),pd.notnull(y))
x = x[ind]
y=y[ind]
x = x.values.reshape(-1,1)
y = y.values.reshape(-1,1)

lr = linear_model.LinearRegression()
lr.fit(x,y)
# print('Coefficients: \n', lr.coef_)
preds = lr.predict(x)
ax.set_title('R2=%.3f\nRMSE=%.2f\nN=%.0f' % (r2_score(y,preds),
mean_squared_error(y,preds),
len(x)))
return ax
#%%
def multi_plot(data_out,
sites = ['KAN_M', 'KAN_U'],sp1 = 4, sp2 = 2,
title = '', OutputFolder='figures/',
Expand Down Expand Up @@ -267,5 +304,36 @@ def mosaic_albedo_fit(df, Rad_in):
ax[i, j].set_ylim([0.01, 1.05])
ax[i, j].grid(True)
fig.savefig('./output/linear_'+Rad_in+'oa.png',bbox_inches='tight')
#%%
def overall_axis_label(fig, xlab, ylab):
ax0 = fig.add_subplot(111) # The big subplot

# Turn off axis lines and ticks of the big subplot
ax0.spines['top'].set_color('none')
ax0.spines['bottom'].set_color('none')
ax0.spines['left'].set_color('none')
ax0.spines['right'].set_color('none')
ax0.tick_params(labelcolor='w', top=False, bottom=False, left=False, right=False)
ax0.patch.set_visible(False)

# Set common labels
ax0.set_xlabel('Date')

if isinstance(ylab,str):
ax0.set_ylabel(ylab)
ax0_2 = []
else
ax0.set_ylabel(ylab[0])

ax0_2 = ax0.twinx()
ax0_2.set_ylabel(ylab[1])

ax0_2.spines['top'].set_color('none')
ax0_2.spines['bottom'].set_color('none')
ax0_2.spines['left'].set_color('none')
ax0_2.spines['right'].set_color('none')
ax0_2.tick_params(labelcolor='w', top=False, bottom=False, left=False, right=False)

ax0_2.patch.set_visible(False)
return ax0, ax0_2

227 changes: 0 additions & 227 deletions bav_lib.py.bak

This file was deleted.

Binary file removed misc/astmg173.xls
Binary file not shown.
22 changes: 22 additions & 0 deletions misc/gains_olci.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
platform,band,wavelength,average_gain,standard_deviation
A,1,400,0.975458,0.005544
A,2,412.5,0.974061,0.005897
A,3,442.5,0.974919,0.005435
A,4,490,0.968897,0.005645
A,5,510,0.971844,0.004139
A,6,560,0.975705,0.003086
A,7,620,0.980013,0.002107
A,8,665,0.978339,0.001412
A,9,673.75,0.978597,0.002128
A,10,681.25,0.979083,0.001504
A,11,708.75,0.980135,0.004555
A,12,753.75,0.985516,0.003723
A,13,761.25,1,0
A,14,764.375,1,0
A,15,767.5,1,0
A,16,778.75,0.987718,0.00352
A,17,865,0.986,
A,18,885,0.986569,0.00176
A,19,900,1,0
A,20,940,1,0
A,21,1020,0.913161,0.008537
Binary file removed misc/olci_bands.xlsx
Binary file not shown.
Loading

0 comments on commit 8aa1fcb

Please sign in to comment.