File size: 707 Bytes
f3b050a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import torch
import math
import numpy as np
from copy import deepcopy
path_load = '/data/weather2025/NhaBe/train/rad'
path_save = '/data/weather2025/NhaBe'
num = 0
rad_clim = {}
for name in os.listdir(path_load):
    file = np.load(os.path.join(path_load,name))
    for field in file.keys():
        if(num == 0): 
            rad_clim[field] = file[field]
        else:
            rad_clim[field] = rad_clim[field] + file[field]
    num += 1 
    print(num,end='\r')
for field in rad_clim.keys(): 
    rad_clim[field] = rad_clim[field]/num 
    rad_clim[field] = np.expand_dims(rad_clim[field],axis =0)
    print(rad_clim[field].shape)
np.savez(os.path.join(path_save,'rad_clim.npz'),**rad_clim)