Skip to content
Snippets Groups Projects
Commit 8129a24b authored by xuetaowave's avatar xuetaowave
Browse files

update

parent ee72b125
No related merge requests found
%% Cell type:code id:initial_id tags:
``` python
import numpy as np
import h5py
```
%% Cell type:code id:152ab0a0c8eecc72 tags:
``` python
data_load = h5py.File('train/2010.h5', 'r')
data_load.keys()
```
%% Output
<KeysViewHDF5 ['fields']>
%% Cell type:code id:f25578284e85faed tags:
``` python
data = data_load['fields']
global_mean = np.mean(data, axis=(0, 2, 3))[None, :, None, None]
print(global_mean.shape)
np.save('global_means.npy', global_mean)
```
%% Output
(1, 30, 1, 1)
%% Cell type:code id:c70926d3068ad7ac tags:
``` python
global_stds = np.std(data, axis=(0, 2, 3))[None, :, None, None]
np.save('global_stds.npy', global_stds)
```
%% Cell type:code id:e5d84c8e9cb760d8 tags:
``` python
time_means = np.mean(data, axis=0)[None]
print(time_means.shape)
np.save('time_means.npy', time_means)
```
%% Output
(1, 30, 192, 288)
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import numpy as np
import h5py
# In[2]:
data_load = h5py.File('train/2010.h5', 'r')
data_load.keys()
# In[3]:
data = data_load['fields']
global_mean = np.mean(data, axis=(0, 2, 3))[None, :, None, None]
print(global_mean.shape)
np.save('global_means.npy', global_mean)
# In[4]:
global_stds = np.std(data, axis=(0, 2, 3))[None, :, None, None]
np.save('global_stds.npy', global_stds)
# In[5]:
time_means = np.mean(data, axis=0)[None]
print(time_means.shape)
np.save('time_means.npy', time_means)
Source diff could not be displayed: it is too large. Options to address this: view the blob.
%% Cell type:code id: tags:
``` python
import numpy as np
import h5py
```
%% Cell type:code id: tags:
``` python
data_load_D = np.load('Density.npz')
D = data_load_D['fields']
data_load_P = np.load('P.npz')
P = data_load_P['fields']
data_load_T = np.load('T.npz')
T = data_load_T['fields']
data_load_U = np.load('U.npz')
U = data_load_U['fields']
data_load_V = np.load('V.npz')
V = data_load_V['fields']
list(data_load_D.keys()), D.shape, P.shape, T.shape, U.shape, V.shape
```
%% Output
(['fields', 'date'],
(16992, 192, 288),
(16992, 192, 288),
(16992, 192, 288),
(16992, 192, 288),
(16992, 192, 288))
%% Cell type:code id: tags:
``` python
data = np.hstack((D.reshape((-1, 6)+D.shape[1:]), P.reshape((-1, 6)+P.shape[1:]), T.reshape((-1, 6)+T.shape[1:]), U.reshape((-1, 6)+U.shape[1:]), V.reshape((-1, 6)+V.shape[1:])))
train_mask = data.shape[0]//6*5
```
%% Cell type:code id: tags:
``` python
import os
print(os.getcwd())
os.makedirs('train', exist_ok=True)
os.makedirs('test', exist_ok=True)
os.makedirs('out_of_sample', exist_ok=True)
```
%% Output
/mnt/data/work/FourCastNet/data_ljkj
%% Cell type:code id: tags:
``` python
import h5py
with h5py.File('train/2010.h5', 'w') as f:
f.create_dataset("fields", data=data[:train_mask])
with h5py.File('test/2010.h5', 'w') as f:
f.create_dataset("fields", data=data[train_mask:])
with h5py.File('out_of_sample/2010.h5', 'w') as f:
f.create_dataset("fields", data=data[train_mask:])
```
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment