Page MenuHomec4science

quick.py
No OneTemporary

File Metadata

Created
Sun, Apr 27, 22:41

quick.py

import numpy as np
import pandas as pd
import xarray as xr
import os
import time
from features import Training, Testing
from tables import open_file, Atom, Filters
import util
################################ INPUTS ################################
#data_path = os.path.abspath("/Users/alinawalch/Documents/EPFL/data/meteo") # folder in which raw data is stored
data_path = os.path.abspath("/mnt/sda1/hyenergy/data/meteo")
# List of features and tables
ftrs = ['_3D','_6D']
ftr_lists = (['x','y','z','month','hour'],['x','y','z','medDoG','big_NS','big_EW','month','hour'])
lbl_list = ['SIS']
locmask = 'all'
# locmasks = ['rand100']
t_mask = 'grid'
# querynames = ['query_locs_13d_2000']
queryname = 'query_locs_13d_500'
ds = 2001
hours = list(range(3,20))
months = list(range(1,13))
for ftr,ftr_list in zip(ftrs, ftr_lists):
# get precise number of training and testing locations
mask = np.loadtxt('locations/%s.txt' %locmask)
n_mask = np.sum(mask)
# set location masks for the training and test
train_locs = "locations/"+locmask+"_train.txt"
test_locs = "locations/"+locmask+"_test.txt"
dsname = str(ds) + '_' + locmask + '_SIS' + ftr
print('Making datasets ... ')
t_set = util.Timer()
new_set = Training(data_path, dsname, ftr_list, lbl_list)
new_set.make_dataset(year = ds, sample_name = train_locs, test_name = test_locs)
new_set.normalize_all(feature_norm = 'mean', target_norm = 'mean', val_ratio = 1.0)
# queryname = querynames[0]
print('Making query dataset for %s' %queryname)
myquery = Testing(data_path, dsname, query_name = queryname)
myquery.make_query(loc = queryname+'.csv', hour = hours, month = months)
myquery.normalize_input()
t_set.stop(print_wallclock = False)

Event Timeline