本文整理汇总了Python中FileIO.loadFile方法的典型用法代码示例。如果您正苦于以下问题:Python FileIO.loadFile方法的具体用法?Python FileIO.loadFile怎么用?Python FileIO.loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileIO
的用法示例。
在下文中一共展示了FileIO.loadFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import loadFile [as 别名]
def main(*arguements):
# --------------------------------------------------------
# Parse command line, to fetch session input file
# --------------------------------------------------------
if len(sys.argv) >= 2:
ripFilePath = sys.argv[1]
# If user did not specify .rip file
else:
print "User must specify input file name (e.g., at command line type GARM.py user_input.rip)."
sys.exit(-1)
# If .ip file does not exist
if not os.path.exists(ripFilePath):
print ("Cannot find or open runtime inputs file(%s)" % (ripFilePath))
sys.exit(-1)
dir = "tree100perlandscape/"
# bird_types = ['St','Mu','Gl','Cr','Ax',Sh,Tu
# Skipped Du, Re, Ru
bird_types = ["Ha"]
file_types = ["_tree_100_1_10.asc", "_tree_100_1_100.asc"]
# file_types = ['_tree_100_1_2.asc','_tree_100_1_5.asc','_tree_100_1_10.asc','_tree_100_1_100.asc']
grid_file_out = "aus_bird_unicor.rip"
for bird in bird_types:
for type in file_types:
print "now running " + bird + type
header_dict, data = FileIO.loadFile(ripFilePath, header_lines=16)
header_dict["XY_Filename"] = str(bird + "_XY.csv")
header_dict["Grid_Filename"] = str(dir + bird + type)
header_dict["Session_label"] = bird + "_type"
FileIO.outputGrid(grid_file_out, ["null", "null"], header_dict=header_dict)
cd_matrix = RunUNICOR(grid_file_out)
示例2: main
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import loadFile [as 别名]
#.........这里部分代码省略.........
stringpts,visited,EDthresholdans,num_of_pro \
,nWeightPairs,xvalues,yvalues,pathadd,cd_matrix,paths,edge_type, \
edge_dist,transform_func,const_kernal_vol, vol_constant,nbhd_dist)
# Retrieve return values here from tuple above
if not directionans:
pathadd = tupSpaths[0]
cd_matrix = tupSpaths[1]
paths = tupSpaths[2]
else:
#pathadd_rev = tupSpaths_rev[0]
#cd_matrix_rev = tupSpaths_rev[1]
#paths_rev = tupSpaths_rev[2]
pathadd_lower = tupSpaths_lower[0]
cd_matrix_lower = tupSpaths_lower[1]
paths_lower = tupSpaths_lower[2]
pathadd_upper = tupSpaths_upper[0]
cd_matrix_upper = tupSpaths_upper[1]
paths_upper = tupSpaths_upper[2]
# Lower is ordered 1,2. Upper is reversed 2,1
# User Lower lower triangle, upper lower triangle to fill upper triangle.
# Careful, stringpts and stringpts_rev are reversed!
#if dirtype == 'Wind': # Just for wind also get cost
# cd_matrix_upper_accCost = tupSpaths_upper[3]
# cd_matrix_lower_accCost = tupSpaths_lower[3]
# Print to log
stringout = '\nTotal shortest path calculation run-time: '+\
str(datetime.datetime.now() - start_time)+'\n'
FileIO.logMsg(logfHndl,stringout)
# Get header information, change to -9999 for nodata.
header_dict, data_list = FileIO.loadFile(resgrid,header_lines=6)
res_array = np.asarray(data_list,'float')
pathadd[res_array==-9999] = -9999
# --------------------------------------------------------------------------
# Create output files, and write out important fields
# --------------------------------------------------------------------------
# Do some output filename creation
cd_matrix_ext = '.cdmatrix.csv'
pathadd_ext = '.addedpaths.txt'
paths_ext = '.paths.csv'
buff_ext = '.kdepaths'
lev_ext = '.levels'
Gmets_ext = '.graphmetrics'
# Strip .rsg and .xy from file names
input_file_name = gridfile.rstrip('.rsg')
input_point_name = xyfilename.rstrip('.xy')
# If data is in another directory, clean up more
if len(input_file_name.split('/')) > 1:
data_dir = input_file_name.split('/')[0]+'/'
else:
data_dir = ''
input_file_name = input_file_name.split('/')[-1]
input_point_name = input_point_name.split('/')[-1]
# Output file names defined here
if not directionans:
cd_matrix_file_name = input_file_name + '_' + input_point_name + cd_matrix_ext
pathadd_file_name = input_file_name + '_' + input_point_name + pathadd_ext
paths_file_name = input_file_name + '_' + input_point_name + paths_ext
else: