Append the linke turbidity projected (using lat lon) as variables of
    the netcdf file.

    Keyword arguments:
    filename -- the name of a netcdf file.
555375
def persist(filename):
    
    linkes_projected = obtain_to(filename, compressed=False)
    keys = sorted(linkes_projected.keys())
    values = np.vstack([map(lambda k: linkes_projected[k], keys)])
    with nc.loader(filename) as root:
        data = nc.getvar(root, 'data')
        linke = nc.getvar(root, 'linke', 'f4', source=data)
        linke[:] = values
465907
def _append_filename_extension(self, response: BaseResponse):
        ''''''
        if not self._filename:
            return

        if response.request.url_info.scheme not in ('http', 'https'):
            return

        if not re.search(r'\.[hH][tT][mM][lL]?$', self._filename) and \
                HTMLReader.is_response(response):
            self._filename += '.html'
        elif not re.search(r'\.[cC][sS][sS]$', self._filename) and \
                CSSReader.is_response(response):
            self._filename += '.css'
545074
def set_file(self, filename):
        
        # Use the file name as prefix if none is given
        if self.output_prefix is None:
            _, self.output_prefix = os.path.split(filename)
        # Check if the file is present, since rdpcap will not do that
        if not (os.path.isfile(filename) and os.access(filename, os.R_OK)):
            print 'The file \'{0}\' is either not present or not readable. '\
                  'Exiting!'.format(filename)
            sys.exit(1)
        try:
            packets = rdpcap(filename)
        except NameError:
            # Due probably to a bug in rdpcap, this kind of error raises a
            # NameError, because the exception that is tried to raise, is not
            # defined
            print 'The file \'{}\' is not a pcap capture file. Exiting!'\
                .format(filename)
            sys.exit(2)

        for number, packet in enumerate(packets):
            # See if there is a field called load
            self._debug('\nNUMBER {0}'.format(number), no_prefix=True)
            try:
                # Will cause AttributeError if there is no load
                packet.getfieldval('load')
                # Get the full load
                load = packet.sprintf('%TCP.payload%')
                self._debug('PAYLOAD LENGTH {0}'.format(len(load)),
                            no_prefix=True)
                self._debug(load, load=True)
                self._parse_load(load)
            except AttributeError:
                self._debug('LOAD EXCEPTION', no_prefix=True)
        if len(self.messages) > 0 and not self.messages[-1].write_closed:
            self._debug('DELETE LAST OPEN FILE')
            del self.messages[-1]

        if self.args.debug_analysis:
            sys.exit(0)
438512
def obtain_to(filename):
    
    root, _ = nc.open(filename)
    lat, lon = nc.getvar(root, 'lat')[0,:], nc.getvar(root, 'lon')[0,:]
    nc.close(root)
    return obtain(lat, lon)
1274261
def add_file_argument(self, *args, **kwargs):
        
        rval = self.add_argument(*args, **kwargs)
        self.file_args.append(rval)
        return rval
657929
def load_data_and_build(self, filename, delimiter=","):
        
        data = np.genfromtxt(
            filename, dtype=float, delimiter=delimiter, names=True
        )
        data = data.view(np.float64).reshape(data.shape + (-1,))

        X = data[:, 0:-1]
        Y = data[:, -1]

        self.build(X=X, Y=Y)
599131
def generate_tensor_filename(self, field_name, file_num, compressed=True):
        
        file_ext = TENSOR_EXT
        if compressed:
            file_ext = COMPRESSED_TENSOR_EXT
        filename = os.path.join(self.filename, 'tensors', '%s_%05d%s' %(field_name, file_num, file_ext))
        return filename
1314250
def sharded_filenames(filename_prefix, num_shards):
  """"""
  shard_suffix = "%05d-of-%05d"
  return [
      "%s-%s" % (filename_prefix, shard_suffix % (i, num_shards))
      for i in range(num_shards)
  ]
1344654
def merge_likelihood_headers(filenames, outfile):
    

    filenames = np.atleast_1d(filenames)

    ext='PIX_DATA'
    nside = fitsio.read_header(filenames[0],ext=ext)['LKDNSIDE']
    
    keys=['STELLAR','NINSIDE','NANNULUS']
    data_dict = odict(PIXEL=[])
    for k in keys:
        data_dict[k] = []

    for i,filename in enumerate(filenames):
        logger.debug('(%i/%i) %s'%(i+1, len(filenames), filename))
        header = fitsio.read_header(filename,ext=ext)
        data_dict['PIXEL'].append(header['LKDPIX'])
        for key in keys:
            data_dict[key].append(header[key])

        del header
        
    data_dict['PIXEL'] = np.array(data_dict['PIXEL'],dtype=int)
    for key in keys:
        data_dict[key] = np.array(data_dict[key],dtype='f4')

    #import pdb; pdb.set_trace()
    write_partial_map(outfile, data_dict, nside)
    return data_dict
749907
def _decode_filename(base_filename, problem_name, decode_hp):
  
  if decode_hp.shards > 1:
    base_filename = _add_shard_to_filename(base_filename, decode_hp)
  if ("beam{beam}.alpha{alpha}.decodes".format(
      beam=str(decode_hp.beam_size), alpha=str(decode_hp.alpha))
      in base_filename):
    return base_filename
  else:
    return (
        "{base}.{model}.{hp}.{problem}.beam{beam}.alpha{alpha}.decodes".format(
            base=base_filename,
            model=FLAGS.model,
            hp=FLAGS.hparams_set,
            problem=problem_name,
            beam=str(decode_hp.beam_size),
            alpha=str(decode_hp.alpha)))
1240270
def save_parameters(self, filename):
        
        params = self._collect_params_with_prefix()
        if self.pret_word_embs:  # don't save word embeddings inside model
            params.pop('pret_word_embs.weight', None)
        arg_dict = {key: val._reduce() for key, val in params.items()}
        ndarray.save(filename, arg_dict)
231644
def add_input_file(self, filename):
    
    if filename not in self.__input_files:
      self.__input_files.append(filename)
532278
function appendFilename(pathStr, valueToAppend) {
  var pfile = path.parse(pathStr);
  var result = Array.prototype.join.call([
    pfile.dir,
    '/',
    pfile.name,
    valueToAppend,
    pfile.ext
  ], '');
  return result;
}
1272422
def add_file(self, file, filename):
        
        self.files['_{}'.format(filename)] = (filename, file)
733923
def obtain_to(filename, compressed=True):
    
    files = glob.glob(filename)
    root, _ = nc.open(filename)
    lat, lon = nc.getvar(root, 'lat')[0,:], nc.getvar(root, 'lon')[0,:]
    date_str = lambda f: ".".join((f.split('/')[-1]).split('.')[1:-2])
    date = lambda f: datetime.strptime(date_str(f), "%Y.%j.%H%M%S")
    linke = lambda f: transform_data(obtain(date(f), compressed), lat, lon)
    linkes_projected = map(lambda f: (f, linke(f)), files)
    nc.close(root)
    return dict(linkes_projected)
180760
def save(self, filename):
        
        file_root, file_ext = os.path.splitext(filename)
        if file_ext == '.npy':
            np.save(filename, self._data)
        elif file_ext == '.npz':
            np.savez_compressed(filename, self._data)
        else:
            raise ValueError('Extension %s not supported for point saves.' %(file_ext))
433802
def save(self, filename):
        
        gz = filename.endswith('.gz')
        ligolw_utils.write_filename(self.outdoc, filename, gz=gz)