-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_vod_df.py
74 lines (33 loc) · 1.61 KB
/
make_vod_df.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 30 00:35:32 2017
@author: kkrao
"""
## Makes mort df from mort_summary df
from __future__ import division
from dirs import *
arcpy.env.overwriteOutput=True
year_range=range(2005,2016)
date_range=range(1,367,1)
factor=1e4
arcpy.env.workspace = Dir_mort+'/CA_proc.gdb'
os.chdir(Dir_mort+'/CA_proc.gdb')
nos=370 # number of grid cells
vodDf=pd.DataFrame()
vodDf.index.name='gridID'
pass_type = 'D'; #Type the overpass: 'A' or 'D'
for k in year_range:
year = '%s' %k #Type the year
for j in date_range:
date='%03d'%j
sys.stdout.write('\r'+'Processing data for '+year+' '+date+' ...')
sys.stdout.flush()
vod=pd.DataFrame(np.full(nos,np.nan), columns=[year+date+pass_type])
fname="VOD_stats_%s_%s_%s" %(year,date,pass_type)
if arcpy.Exists(fname):
cursor = arcpy.SearchCursor(fname)
for row in cursor:
vod.iloc[row.getValue('gridID')-1]=row.getValue('MEAN')/factor# grid ID is 1 to 370
vodDf=pd.concat([vodDf,vod],axis=1)
store = pd.HDFStore(Dir_CA+'/vod_D_Df.h5')
store['vod_D_Df'] = vodDf