Skip to content

Commit 943d3c6

Browse files
committed
Updated a number of functions to work better with ICEPack Output
1 parent 978c0d5 commit 943d3c6

16 files changed

Lines changed: 927 additions & 23 deletions

Untitled.ipynb

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 4,
6+
"id": "14148bd2-6f71-4fe3-8fb1-c16533bf9190",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import sys\n",
11+
"sys.path.append('/mnt/data01/Code/')\n",
12+
"import NDH_Tools as ndh\n",
13+
"\n",
14+
"import mat73"
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": 5,
20+
"id": "07d07ffd-d284-4fd7-8fe0-3c41487eda3f",
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"fn = '/home/nholschuh/Drive/Research_Projects/74_Multipass/PetermannWork/Picking_iPad/Picked/Data_20110429_01_010_fs_25_crop_1065.pdf'\n",
25+
"\n",
26+
"\n",
27+
"local_fn_whole = fn.split('/')[-1]\n",
28+
"fileparts = local_fn_whole.split('.')[0].split('_')\n",
29+
"\n",
30+
"fs = int(fileparts[5])\n",
31+
"crop = int(fileparts[7])\n",
32+
"day_seg = '_'.join(fileparts[1:3])\n",
33+
"local_fn = '_'.join(fileparts[0:4])\n",
34+
"data_dir = '/mnt/data01/Data/RadarData/CReSIS_Filestructure/ct_data/rds/2011_Greenland_P3/'\n",
35+
"surf_load = 'CSARP_surf_ndh'\n",
36+
"fn = data_dir+surf_load+'/'+day_seg+'/'+local_fn+'.mat'"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 6,
42+
"id": "ce6643b2-1acf-4cea-b666-a5c8febe7fdd",
43+
"metadata": {},
44+
"outputs": [],
45+
"source": [
46+
"surf_data = mat73.loadmat(fn)\n",
47+
"ndh.savemat(surf_data,'test.mat')"
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"id": "862a104c-a9aa-44e3-bd88-2b08c9e3c6d0",
54+
"metadata": {},
55+
"outputs": [],
56+
"source": [
57+
"!ls /mnt/data01/Data/RadarData/CReSIS_Filestructure/ct_data/rds/2011_Greenland_P3/CSARP_surf_ndh/20110429_01/"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"id": "ee60fdb1-1aae-41e1-a135-bccefa835e3e",
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"scipy.io.loadmat(fn)"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": null,
73+
"id": "d94cf1f1-6b82-41a7-926b-537bacffc72c",
74+
"metadata": {},
75+
"outputs": [],
76+
"source": [
77+
"data = read_h5(fn)\n",
78+
"data"
79+
]
80+
},
81+
{
82+
"cell_type": "code",
83+
"execution_count": null,
84+
"id": "bd7251ce-c037-485c-88ab-48c08ec9f8a1",
85+
"metadata": {},
86+
"outputs": [],
87+
"source": [
88+
"data = mat73.loadmat(fn)"
89+
]
90+
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": null,
94+
"id": "77250c20-1682-4d7e-9f8f-42bb259511c9",
95+
"metadata": {},
96+
"outputs": [],
97+
"source": [
98+
"data"
99+
]
100+
},
101+
{
102+
"cell_type": "code",
103+
"execution_count": null,
104+
"id": "27e3dd33-6962-4482-bdf2-2befd813a4ad",
105+
"metadata": {},
106+
"outputs": [],
107+
"source": []
108+
}
109+
],
110+
"metadata": {
111+
"kernelspec": {
112+
"display_name": "Python 3 (ipykernel)",
113+
"language": "python",
114+
"name": "python3"
115+
},
116+
"language_info": {
117+
"codemirror_mode": {
118+
"name": "ipython",
119+
"version": 3
120+
},
121+
"file_extension": ".py",
122+
"mimetype": "text/x-python",
123+
"name": "python",
124+
"nbconvert_exporter": "python",
125+
"pygments_lexer": "ipython3",
126+
"version": "3.8.10"
127+
},
128+
"widgets": {
129+
"application/vnd.jupyter.widget-state+json": {
130+
"state": {},
131+
"version_major": 2,
132+
"version_minor": 0
133+
}
134+
}
135+
},
136+
"nbformat": 4,
137+
"nbformat_minor": 5
138+
}

calculate_flowlines.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
4+
def calculate_flowlines(x,y,u,v,seed_points,max_error=0.00001):
5+
"""
6+
% (C) Nick Holschuh - Amherst College -- 2022 (Nick.Holschuh@gmail.com)
7+
%
8+
% This function prints out the minimum and maximum values of an array
9+
%
10+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11+
% The inputs are:
12+
%
13+
% input_array -- array of data to analyze
14+
%
15+
%%%%%%%%%%%%%%%
16+
% The outputs are:
17+
%
18+
% output -- the min and max in a 1x2 array
19+
%
20+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21+
"""
22+
23+
################# This uses a modified plt.streamline to pass through a user-editable keyword
24+
################# argument "max_error", which goes into the interpolater to guarantee
25+
################# accurate streammline calculation. Copy this version of streamplot
26+
################# into your matplotlib directory to enable the use of streamline
27+
################# calculation from NDH_Tools
28+
29+
30+
sls = []
31+
32+
if isinstance(seed_points,list):
33+
seed_points = np.array(seed_points)
34+
35+
if len(seed_points.shape) == 1:
36+
seed_points = np.expand_dims(seed_points,axis=0)
37+
38+
fig = plt.figure()
39+
40+
for ind0, sp in enumerate(seed_points[:,0]):
41+
streamlines = plt.streamplot(x,y,u,v,start_points=[seed_points[ind0,:]], max_error=max_error)
42+
43+
44+
########### Here we extract the coordinate information along the streamline
45+
sl = [streamlines.lines.get_paths()[0].vertices[0]]
46+
for i in streamlines.lines.get_paths():
47+
sl.append(i.vertices[1])
48+
49+
sls.append(np.array(sl))
50+
51+
plt.close(fig)
52+
53+
return sls

0 commit comments

Comments
 (0)