adding synthetic.py which creates synthetic cases from cone forecast
[JPSSData.git] / contlinesvm.py
blob88773710785d16ddfe4116ef9f6e479f2fbd47a2
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=svm['Z']*tscale+time_scale_num[0]
23 print 'Computing the contours...'
24 # Granules numeric times
25 time_num_granules = svm['time_num_granules'][0]
26 data = get_contour_verts(xx, yy, zz, time_num_granules, contour_dt_hours=6, contour_dt_init=6, contour_dt_final=6)
28 print 'Creating the KML file...'
29 # Creating the KML file
30 contour2kml(data,'perimeters_svm.kml')
32 print 'perimeters_svm.kml generated'