Changeset 928 for inundation/ga/storm_surge/pyvolution/data_manager.py
- Timestamp:
- Feb 18, 2005, 5:15:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/data_manager.py
r900 r928 872 872 dem_elevation = infile.variables['elevation'] 873 873 874 zone = infile.zone[0] 875 false_easting = infile.false_easting[0] 876 false_northing = infile.false_northing[0] 877 878 #Text strings 879 projection = infile.projection 880 datum = infile.datum 881 units = infile.units 882 883 874 884 #Get output file 875 885 xyaname = root + '.pts' … … 884 894 885 895 #Georeferencing 886 outfile.zone = 56 #FIXME: Must be read from somewhere. Talk to Don.896 outfile.zone = zone 887 897 outfile.xllcorner = xllcorner #Easting of lower left corner 888 898 outfile.yllcorner = yllcorner #Northing of lower left corner 889 899 outfile.false_easting = false_easting 900 outfile.false_northing =false_northing 901 902 outfile.projection = projection 903 outfile.datum = datum 904 outfile.units = units 905 890 906 891 907 #Grid info (FIXME: probably not going to be used, but heck) … … 938 954 939 955 Convert to NetCDF format (.dem) mimcing the ASCII format closely. 956 957 958 An accompanying file with same basename but extension .prj must exist 959 and is used to fix the UTM zone, datum, false northings and eastings. 960 961 The prj format is assumed to be as 962 963 Projection UTM 964 Zone 56 965 Datum WGS84 966 Zunits NO 967 Units METERS 968 Spheroid WGS84 969 Xshift 0.0000000000 970 Yshift 10000000.0000000000 971 Parameters 940 972 """ 941 973 … … 945 977 946 978 root, ext = os.path.splitext(filename) 947 fid = open(filename) 979 980 ########################################### 981 # Read Meta data 982 if verbose: print 'Reading METADATA from %s' %root + '.prj' 983 metadatafile = open(root + '.prj') 984 metalines = metadatafile.readlines() 985 metadatafile.close() 986 987 L = metalines[0].strip().split() 988 assert L[0].strip().lower() == 'projection' 989 projection = L[1].strip() #TEXT 990 991 L = metalines[1].strip().split() 992 assert L[0].strip().lower() == 'zone' 993 zone = int(L[1].strip()) 994 995 L = metalines[2].strip().split() 996 assert L[0].strip().lower() == 'datum' 997 datum = L[1].strip() #TEXT 998 999 L = metalines[3].strip().split() 1000 assert L[0].strip().lower() == 'zunits' #IGNORE 1001 zunits = L[1].strip() #TEXT 1002 1003 L = metalines[4].strip().split() 1004 assert L[0].strip().lower() == 'units' 1005 units = L[1].strip() #TEXT 1006 1007 L = metalines[5].strip().split() 1008 assert L[0].strip().lower() == 'spheroid' #IGNORE 1009 spheroid = L[1].strip() #TEXT 1010 1011 L = metalines[6].strip().split() 1012 assert L[0].strip().lower() == 'xshift' 1013 false_easting = float(L[1].strip()) 1014 1015 L = metalines[7].strip().split() 1016 assert L[0].strip().lower() == 'yshift' 1017 false_northing = float(L[1].strip()) 1018 1019 #print false_easting, false_northing, zone, datum 1020 1021 1022 ########################################### 1023 #Read DEM data 1024 datafile = open(filename) 948 1025 949 1026 if verbose: print 'Reading DEM from %s' %filename 950 lines = fid.readlines()951 fid.close()1027 lines = datafile.readlines() 1028 datafile.close() 952 1029 953 1030 if verbose: print 'Got', len(lines), ' lines' … … 962 1039 assert len(lines) == nrows + 6 963 1040 1041 1042 ########################################## 1043 1044 964 1045 netcdfname = root + '.dem' 965 1046 if verbose: print 'Store to NetCDF file %s' %netcdfname … … 979 1060 fid.NODATA_value = NODATA_value 980 1061 1062 fid.zone = zone 1063 fid.false_easting = false_easting 1064 fid.false_northing = false_northing 1065 fid.projection = projection 1066 fid.datum = datum 1067 fid.units = units 1068 1069 981 1070 # dimension definitions 982 1071 fid.createDimension('number_of_rows', nrows) … … 1003 1092 1004 1093 1005 1006 1007 1008 1009 1094 def ferret2sww(basefilename, verbose=False, 1010 1095 minlat = None, maxlat =None, 1011 1096 minlon = None, maxlon =None, 1012 1097 mint = None, maxt = None, mean_stage = 0, 1013 origin = (0,0,0 )):1098 origin = (0,0,0,0,0)): 1014 1099 """Convert 'Ferret' NetCDF format for wave propagation to 1015 1100 sww format native to pyvolution. … … 1169 1254 1170 1255 #Check zone boundaries 1171 refzone, _, _ = redfearn(latitudes[0],longitudes[0]) 1256 refzone, _, _ = redfearn(latitudes[0],longitudes[0], 1257 false_easting=origin[3], 1258 false_northing=origin[4]) 1259 1260 1172 1261 1173 1262 vertices = {} … … 1176 1265 vertices[l,k] = i 1177 1266 1178 zone, easting, northing = redfearn(lat,lon) 1267 zone, easting, northing = redfearn(lat,lon, 1268 false_easting=origin[3], 1269 false_northing=origin[4]) 1179 1270 1180 1271 msg = 'Zone boundary crossed at longitude =', lon
Note: See TracChangeset
for help on using the changeset viewer.