fixing typo when encoding a tuple in conf.json
[JPSSData.git] / contlinesvm.py
blob01cf857a8a843e80411f2b6ce80bccfaefca642f
1 import numpy as np
2 from scipy.io import loadmat
3 from contline import get_contour_verts
4 from contour2kml import contour2kml
5 import os
6 import sys
8 matlab_file = 'svm.mat'
9 if os.path.isfile(matlab_file) and os.access(matlab_file,os.R_OK):
10 print 'Loading the data...'
11 svm=loadmat('svm.mat')
12 else:
13 print 'Error: file %s not exist or not readable' % matlab_file
14 sys.exit(1)
16 # Reading the variables in the file
17 xx=np.array(svm['fxlon'])
18 yy=np.array(svm['fxlat'])
19 tscale=svm['tscale'][0]
20 time_scale_num=svm['time_scale_num'][0]
21 zz=np.array(svm['Z'])*tscale+time_scale_num[0]
22 #zn=zz.ravel()
23 #Z=np.reshape(zn,zz.shape,'F')
25 print 'Computing the contours...'
26 # Granules numeric times
27 time_num_granules = svm['time_num_granules'][0]
28 data = get_contour_verts(xx, yy, zz, time_num_granules, contour_dt_hours=6, contour_dt_init=24, contour_dt_final=12)
30 print 'Creating the KML file...'
31 # Creating the KML file
32 contour2kml(data,'perimeters_svm.kml')
34 print 'perimeters_svm.kml generated'