本文整理汇总了Python中utils.make_dir函数的典型用法代码示例。如果您正苦于以下问题:Python make_dir函数的具体用法?Python make_dir怎么用?Python make_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_dir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: clone_wps
def clone_wps(self, tgt, vtables, with_files):
"""
Clone the WPS installation directory (self.wps_idir) together with the chosen table files vtables
and additional files with_files. The WPS clone is created in directory tgt.
:param tgt: target directory into which WPS is cloned
:param vtables: a dictionary with keys from list ['geogrid_vtable', 'ungrib_vtable', 'metgrid_vtable'],
which contain paths of the variable tables relative to 'etc/vtables'
:param with_files: a list of files from the WPS source directory that should be symlinked
:return:
"""
src = self.wps_idir
vtable_locs = self.vtable_locations
# build a list of all files that are simply symlinked
symlinks = list(self.wps_exec_files)
symlinks.extend(with_files)
# create target directory (and all intermediate subdirs if necessary)
make_dir(tgt)
# clone all WPS executables
map(lambda x: symlink_unless_exists(osp.join(src, x), osp.join(tgt, x)), symlinks)
# clone all vtables (build symlink name, ensure directories exist, create the symlink)
for vtable_id, vtable_path in vtables.iteritems():
# build path to link location
symlink_path = osp.join(tgt, vtable_locs[vtable_id])
if not osp.exists(symlink_path):
symlink_tgt = osp.join(self.sys_idir, "etc/vtables", vtable_path)
symlink_unless_exists(symlink_tgt, ensure_dir(symlink_path))
开发者ID:islenv,项目名称:wrfxpy,代码行数:32,代码来源:wrf_cloner.py
示例2: __init__
def __init__(self, app):
"""Create webpages and save them as HTML files
"""
#index.html
print "\n- Creazione pagina web:\nindex.html"
homePage = os.path.join("html", "index.html")
homePageCode = Homepage(app).code
self.save_html_file(homePage, homePageCode)
#Subpages with lists of errors or GPX files links
#Read errors per region from database
print "\n- Creazione sottopagine:"
for check in app.checks.values():
print " %s" % check.name
if "Lista" in check.output or "Mappa" in check.output:
if "Lista" in check.output:
#Subpage displays errors as a list of JOSM remote links
subPage = os.path.join("html", "%s.html" % check.name)
subPageCode = ListSubpage(check).code
if "Mappa" in check.output:
#Subpage displays errors on a clickable map with JOSM remote links
subPageDir = os.path.join("html", check.name)
utils.make_dir(subPageDir)
subPage = os.path.join(subPageDir, "%s.html" % check.name)
subPageCode = MapSubpage(check).code
self.save_html_file(subPage, subPageCode)
if not app.args.NOFX:
homepage = os.path.join("html", "index.html")
call("firefox %s" % homepage, shell=True)
开发者ID:marcobra,项目名称:errori-in-osm,代码行数:30,代码来源:WebPages.py
示例3: plot_perm_ttest_results
def plot_perm_ttest_results(events_id, inverse_method='dSPM', plot_type='scatter_plot'):
print('plot_perm_ttest_results')
all_data = defaultdict(dict)
fsave_vertices = [np.arange(10242), np.arange(10242)]
fs_pts = mne.vertex_to_mni(fsave_vertices, [0, 1], 'fsaverage', LOCAL_SUBJECTS_DIR) # 0 for lh
for cond_id, cond_name, patient, hc, data in patients_hcs_conds_gen(events_id, True, inverse_method):
all_data[patient][hc] = data[()]
print(all_data.keys())
for patient, pat_data in all_data.iteritems():
print(patient)
fol = op.join(LOCAL_ROOT_DIR, 'permutation_ttest_results', patient)
utils.make_dir(fol)
if op.isfile(op.join(fol, 'perm_ttest_points.npz')):
d = np.load(op.join(fol, 'perm_ttest_points.npz'))
if plot_type == 'scatter_plot':
points, values = d['points'][()], d['values'][()]
elif plot_type == 'pysurfer':
vertices, vertives_values = d['vertices'][()], d['vertives_values'][()]
else:
points, values, vertices, vertives_values = calc_points(pat_data, fs_pts)
np.savez(op.join(fol, 'perm_ttest_points'), points=points, values=values, vertices=vertices, vertives_values=vertives_values)
max_vals = 8 # int(np.percentile([max(v) for v in values.values()], 70))
print(max_vals)
fol = op.join(fol, '{}_figures'.format(plot_type))
utils.make_dir(fol)
if plot_type == 'scatter_plot':
scatter_plot_perm_ttest_results(points, values, fs_pts, max_vals, fol)
elif plot_type == 'pysurfer':
pysurfer_plot_perm_ttest_results(vertices, vertives_values, max_vals, fol)
开发者ID:ofek-schechner,项目名称:mmvt,代码行数:29,代码来源:meg_statistics.py
示例4: save
def save(self,path,name):
for proj,postfix in zip(self.projections,DIRS):
proj_path=path+"/"+postfix
utils.make_dir(proj_path)
full_path=proj_path+name
print(full_path)
utils.save_img(full_path,proj)
开发者ID:tjacek,项目名称:deep_shape_context,代码行数:7,代码来源:projections.py
示例5: train_model
def train_model(model, batch_gen, num_train_steps, weights_fld):
saver = tf.train.Saver() # defaults to saving all variables - in this case embed_matrix, nce_weight, nce_bias
initial_step = 0
utils.make_dir('checkpoints')
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
ckpt = tf.train.get_checkpoint_state(os.path.dirname('checkpoints/checkpoint'))
# if that checkpoint exists, restore from checkpoint
if ckpt and ckpt.model_checkpoint_path:
saver.restore(sess, ckpt.model_checkpoint_path)
total_loss = 0.0 # we use this to calculate late average loss in the last SKIP_STEP steps
writer = tf.summary.FileWriter('improved_graph/lr' + str(LEARNING_RATE), sess.graph)
initial_step = model.global_step.eval()
for index in range(initial_step, initial_step + num_train_steps):
centers, targets = next(batch_gen)
feed_dict={model.center_words: centers, model.target_words: targets}
loss_batch, _, summary = sess.run([model.loss, model.optimizer, model.summary_op],
feed_dict=feed_dict)
writer.add_summary(summary, global_step=index)
total_loss += loss_batch
if (index + 1) % SKIP_STEP == 0:
print('Average loss at step {}: {:5.1f}'.format(index, total_loss / SKIP_STEP))
total_loss = 0.0
saver.save(sess, 'checkpoints/skip-gram', index)
开发者ID:XJTUeducation,项目名称:stanford-tensorflow-tutorials,代码行数:26,代码来源:04_word2vec_visualize.py
示例6: main
def main(asmstats, outdir, size_field=False, names=False, colors=False, shapes=False):
#DTYPE = [('sum_purest_bases', '<f8'), ('sum_bases', '<i8'), ('kmer_type', '|S3'), ('n50', '<i8'), ('trim_n', '<i8'), ('kmax', '|S3'), ('trim_n_mapping', '<i8'), ('l50', '<i8'), ('name', '|S6'), ('global_purity', '<f8'), ('cut_off', '<i8'), ('aln_purity', '<f8'), ('kmin', '|S3'), ('sum_ref_lengths', '<i8'), ('metagenome_cov', '<f8'), ('kmer_size', '|S3'), ('aln_ratio', '<f8'), ('asm_type', '|S3'), ('max_contig_length', '<i8')]
a = np.genfromtxt(asmstats, names=True, dtype=None, delimiter=DELIMITER, missing_values=MISSING_VALUE, usemask=True)
#avalues = []
#for asms in asmstats:
# avalues.append(tuple(open(asms).readlines()[1].strip().split(DELIMITER)))
#a = np.array(avalues, dtype=DTYPE)
# Determine l50 limit before filtering names
assert (max(a["l50"]) / 10) > 0
l50xlim = [0, max(a["l50"]) + (max(a["l50"]) / 10)]
# If names are specified, filter by given names
if names:
a = a[np.in1d(a["name"], names)]
make_dir(outdir)
p1 = plot_per_row_legend_n_save(a, "l50", "global_purity", "name", "L50", "Global purity", outdir, xlim=l50xlim, ylim=[0, 1], size_field=size_field, colors=colors, shapes=shapes, names=names)
p2 = plot_per_row_legend_n_save(a, "l50", "aln_purity", "name", "L50", "Alignment purity", outdir, xlim=l50xlim, ylim=[0, 1], size_field=size_field, colors=colors, shapes=shapes, names=names)
p3 = plot_per_row_legend_n_save(a, "l50", "aln_ratio", "name", "L50", "Alignment ratio", outdir, xlim=l50xlim, ylim=[0, 1], size_field=size_field, colors=colors, shapes=shapes, names=names)
p4 = plot_per_row_legend_n_save(a, "l50", "metagenome_cov", "name", "L50", "Metagenome coverage", outdir, xlim=l50xlim, ylim=[0, 1], size_field=size_field, colors=colors, shapes=shapes, names=names)
# Output plots in HTML
sdir = os.path.dirname(os.path.realpath(__file__))
template = open(sdir + '/template/cmp-asm-template.html').read()
with open(outdir + '/index.html', 'w') as fh:
fh.write(template.format(assemblies=" ".join(np.unique(a["name"]).tolist()),
plot1=p1,
plot2=p2,
plot3=p3,
plot4=p4))
开发者ID:alneberg,项目名称:masmvali,代码行数:32,代码来源:plot_comp_asm.py
示例7: standarize_actions
def standarize_actions(in_path, out_path):
action_frame = actions.read_action_frame(in_path)
utils.make_dir(out_path)
for action in action_frame["Action"]:
print(action)
discretize_action(action)
actions.save_action(out_path, action)
开发者ID:tjacek,项目名称:autoencoder_frames,代码行数:7,代码来源:preproc.py
示例8: save
def save(self,path):
utils.make_dir(path)
name=utils.get_name(path)
for proj_type in DIRS:
utils.make_dir(path+'/'+proj_type)
for i,frame in enumerate(self.frames):
frame.save(path,name+str(i))
开发者ID:tjacek,项目名称:autoencoder_frames,代码行数:7,代码来源:projections.py
示例9: main
def main():
with tf.variable_scope('input') as scope:
# use variable instead of placeholder because we're training the intial image to make it
# look like both the content image and the style image
input_image = tf.Variable(np.zeros([1, IMAGE_HEIGHT, IMAGE_WIDTH, 3]), dtype=tf.float32)
utils.download(VGG_DOWNLOAD_LINK, VGG_MODEL, EXPECTED_BYTES)
utils.make_dir('checkpoints')
utils.make_dir('outputs')
model = vgg_model.load_vgg(VGG_MODEL, input_image)
model['global_step'] = tf.Variable(0, dtype=tf.int32, trainable=False, name='global_step')
content_image = utils.get_resized_image(CONTENT_IMAGE, IMAGE_HEIGHT, IMAGE_WIDTH)
content_image = content_image - MEAN_PIXELS
style_image = utils.get_resized_image(STYLE_IMAGE, IMAGE_HEIGHT, IMAGE_WIDTH)
style_image = style_image - MEAN_PIXELS
model['content_loss'], model['style_loss'], model['total_loss'] = _create_losses(model,
input_image, content_image, style_image)
###############################
## TO DO: create optimizer
model['optimizer'] = tf.train.AdamOptimizer(LR).minimize(model['total_loss'],
global_step=model['global_step'])
###############################
model['summary_op'] = _create_summary(model)
initial_image = utils.generate_noise_image(content_image, IMAGE_HEIGHT, IMAGE_WIDTH, NOISE_RATIO)
train(model, input_image, initial_image)
开发者ID:XJTUeducation,项目名称:stanford-tensorflow-tutorials,代码行数:28,代码来源:style_transfer.py
示例10: _load
def _load(self, account):
self.account = account
# Create home directory
utils.make_dir("")
self.configfile = utils.get_root_filename("config.json")
# Create user directory
userfolder = "%s.%s" % (account["username"], account["api"])
utils.make_dir(userfolder)
self.msg.info(
self.name,
"Trackma v{0} - using account {1}({2}).".format(utils.VERSION, account["username"], account["api"]),
)
self.msg.info(self.name, "Reading config files...")
try:
self.config = utils.parse_config(self.configfile, utils.config_defaults)
except IOError:
raise utils.EngineFatal("Couldn't open config file.")
# Load hook file
if os.path.exists(utils.get_root_filename("hook.py")):
import sys
sys.path[0:0] = [utils.get_root()]
try:
self.msg.info(self.name, "Importing user hooks (hook.py)...")
global hook
import hook
self.hooks_available = True
except ImportError:
self.msg.warn(self.name, "Error importing hooks.")
del sys.path[0]
开发者ID:Logmytech,项目名称:trackma,代码行数:35,代码来源:engine.py
示例11: __init__
def __init__(self, report_dir=None,
plot_map_params=None, save_params=None, safe_dir=True):
self.report_dir = report_dir or tempfile.mkdtemp(prefix='report_')
make_dir(self.report_dir, safe=safe_dir, strict=False)
self.plot_map_params = _check_plot_map_params(plot_map_params)
self.save_params = _check_save_params(save_params)
开发者ID:GaelVaroquaux,项目名称:nignore,代码行数:7,代码来源:reporting.py
示例12: save_action
def save_action(path,action):
action_path=path+str(action)+"/"
utils.make_dir(action_path)
for i,img in enumerate(action.images):
img_path=action_path+str(action)+"_"+str(i)
img=np.reshape(img,(80,40))
utils.save_img(img_path,img)
开发者ID:tjacek,项目名称:autoencoder_frames,代码行数:7,代码来源:actions.py
示例13: purge_account
def purge_account(self, num):
"""
Renames stale cache files for account number **num**.
"""
account = self.accounts['accounts'][num]
userfolder = "%s.%s" % (account['username'], account['api'])
utils.make_dir(userfolder + '.old')
utils.regex_rename_files('(.*.queue)|(.*.info)|(.*.list)|(.*.meta)', userfolder, userfolder + '.old')
开发者ID:Logmytech,项目名称:trackma,代码行数:8,代码来源:accounts.py
示例14: show_category
def show_category(dim,size,params):
out_path=params['out_path']
utils.make_dir(out_path)
actions=data.read_actions(params['action_path'])
extr=sda.read_sda(params['cls_path'],params['conf_path'])
for i in range(size):
full_path=out_path+"cls"
print(full_path)
apply_cls(dim,i,params,actions,extr)
开发者ID:tjacek,项目名称:autoencoder_frames,代码行数:9,代码来源:test_cls.py
示例15: get_all_clusters
def get_all_clusters(action_path,conf,out_path,n_cls=10):
actions=get_actions(action_path,conf.nn,conf.cls)
symbols=actions[0].symbols
for i in range(n_cls):
cls_symbol=symbols[i]
full_path=out_path+cls_symbol+"/"
print(full_path)
utils.make_dir(full_path)
get_cluster(i,actions,full_path)
开发者ID:tjacek,项目名称:deep_frames,代码行数:9,代码来源:deep_frames.py
示例16: transform_files
def transform_files(in_path,out_path,transform,dirs=False):
utils.make_dir(out_path)
if(dirs):
names=utils.get_dirs(in_path)
else:
names=utils.get_files(in_path)
for name in names:
full_in_path=in_path+name
full_out_path=out_path+name
transform(full_in_path,full_out_path)
开发者ID:tjacek,项目名称:autoencoder_frames,代码行数:10,代码来源:__init__.py
示例17: save_projection
def save_projection(self,out_path):
utils.make_dir(out_path)
paths=['xy/','zx/','zy/']
paths=[out_path+path for path in paths]
[utils.make_dir(path) for path in paths]
imgs_xy=self.get_imgs(pc.ProjectionXY())
utils.save_images(paths[0],imgs_xy)
imgs_xz=self.get_imgs(pc.ProjectionXZ())
utils.save_images(paths[1],imgs_xz)
imgs_zy=self.get_imgs(pc.ProjectionYZ())
utils.save_images(paths[2],imgs_zy)
开发者ID:tjacek,项目名称:autoencoder_frames,代码行数:11,代码来源:action.py
示例18: create_time_series
def create_time_series(conf,dim=0):
action_path=conf['action']
cls_path=conf['cls_ts']
cls_config=conf['cls_config']
out_path=conf['series']
actions=data.read_actions(action_path)
extractor=sda.read_sda(cls_path,cls_config)
all_t_series=[make_action_ts(extractor,action,dim) for action in actions]
utils.make_dir(out_path)
for action_ts in all_t_series:
full_path=out_path+action_ts.name
utils.save_object(action_ts,full_path)
开发者ID:tjacek,项目名称:autoencoder_frames,代码行数:12,代码来源:time_series.py
示例19: combine_images_into_groups
def combine_images_into_groups():
labels, groups = get_groups()
fol = os.path.join(subjects_dir, subject, 'label', '{}_groups_figures'.format(aparc_name))
utils.make_dir(fol)
for group in groups:
group_im = Image.new('RGB', (800,800))
group_images = get_group_images(group)
for view_image_file, coo in zip(group_images, [(0, 0), (0, 400), (400, 0), (400,400)]):
view_img = Image.open(view_image_file)
view_img.thumbnail((400,400))
group_im.paste(view_img, coo)
group_im.save(os.path.join(fol, '{}-{}.jpg'.format(subject, group)))
开发者ID:ofek-schechner,项目名称:mmvt,代码行数:12,代码来源:show_aparc.py
示例20: reconstruct_images
def reconstruct_images(img_frame,ae,out_path):
utils.make_dir(out_path)
imgs=img_frame['Images']
#cats=img_frame['Category']
for i,img in enumerate(imgs):
img=np.reshape(img,(1,3200))
rec_image=ae.get_image(img)
rec_image*=200
img2D=np.reshape(rec_image,(80,40))
img_path=out_path+"img"+str(i)+".png"
print(img_path)
scipy.misc.imsave(img_path,img2D)
开发者ID:tjacek,项目名称:autoencoder_frames,代码行数:12,代码来源:autoencoder.py
注:本文中的utils.make_dir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论