-
Notifications
You must be signed in to change notification settings - Fork 2
/
listData.py
executable file
·58 lines (49 loc) · 1.78 KB
/
listData.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 25 09:39:23 2020
@author: arthur
Script that lists the data runs with the relevant information
"""
import mlflow
from mlflow.tracking import MlflowClient
import xarray as xr
import matplotlib.pyplot as plt
from analysis.utils import select_run, select_experiment
def show_data_sample(forcing, index: int):
"""Plots the data for the given index"""
sample = forcing.isel(time=index)
for var in sample.values():
plt.figure()
if var.name in ('usurf', 'vsurf'):
var.plot(cmap='coolwarm')
plt.figure()
var.plot.hist(bins=100)
elif var.name in ('S_x', 'S_y'):
var.plot(cmap='coolwarm', vmin=-5, vmax=5)
plt.figure()
var.plot.hist(bins=100, range=(-5, 5))
plt.show()
data_experiment_name = select_experiment()
data_experiment = mlflow.get_experiment_by_name(data_experiment_name)
data_experiment_id = data_experiment.experiment_id
runs = mlflow.search_runs(experiment_ids=[data_experiment_id, ])
runs_short = runs[['run_id', 'start_time', 'params.scale', 'params.ntimes',
'params.lat_min', 'params.lat_max',
'params.long_min', 'params.long_max']]
print('Select a run by entering its integer id (0, 1, ...) as listed\
from below, in order to obtain more details.')
print(runs_short)
while True:
selection = input('Select run: ')
try:
selection = int(selection)
except ValueError as e:
break
print(runs.iloc[selection, :])
run_id = runs.iloc[selection, :]['run_id']
client = MlflowClient()
forcing_data = client.download_artifacts(run_id, 'forcing')
forcing = xr.open_zarr(forcing_data)
forcing = forcing / forcing.std()
show_data_sample(forcing, 0)