update file indices attribute `altimetry.data.hydro_data.fileid`
772282
def update_fid_list(self,filename,N):
        '''
        
        '''
        self.filelist_count[self.filelist.index(filename)] = N
        fid=self.fid_list.compress([enum[1][0] == os.path.basename(filename) for enum in enumerate(zip(*(self.filelist,self.fid_list)))])
        self.__dict__.update({'fileid' :np.append(self.fileid,np.repeat(fid,N))})
927083
def update_file(file)
      log "file: #{file}"
      text = File.read(file)
      text = yield text
      File.open(file, 'w') { |f| f.write(text) }
    end
1129797
def update_file path, matcher, currentVersion, nextVersion
      temp_path = "#{path}.autoversion"

      begin
        File.open(path) do |source|
          File.open(temp_path, 'w') do |target|
            source.each do |line|
              if matcher.call(line)
                target.write line.gsub currentVersion.to_s, nextVersion.to_s
              else
                target.write line
              end
            end
          end
        end

        File.rename temp_path, path
      ensure
        File.unlink temp_path if File.file? temp_path
      end
    end
632744
def update(path,value,timestamp=None):
  
  value = float(value)
  fh = None
  try:
    fh = open(path,'r+b')
    return file_update(fh, value, timestamp)
  finally:
    if fh:
      fh.close()
1237062
function updateFilesList(adds, removes, prefix, name, currentVersion) {
    let configuration = loadConfiguration();
    let filesList = configuration.filesList;
    let modified = false;

    // manage custom prefix
    if (prefix) {
        configuration.versionPrefix = prefix;
        modified = true;
        print('new custom version prefix: ' + prefix, 'completed', 'spaced22');
    }

    // manage custom name and currentVersion
    if (name) {
        configuration.name = name;
        modified = true;
        print('new project name: ' + name, 'completed', 'spaced22');
    }
    if (currentVersion) {
        configuration.currentVersion = currentVersion;
        modified = true;
        print('new project currentVersion: ' + currentVersion, 'completed', 'spaced22');
    }

    function findFileInList(fileName) {
        for(i = 0; i < configuration.filesList.length; i++) {
            if (configuration.filesList[i].indexOf(fileName) === 0) {
                return i;
            }
        }
        return -1;
    }

    // manage additions
    if (adds) {
        let addArray = adds.split(',');

        addArray.forEach(function(a, index) {
            let fileData = a.split(':');
            let fileName = fileData[0];
            let fileType = fileData[1];

            let fileString;
            let fileTypeString;

            if (fileType) {
                fileString = a;
                fileTypeString = fileType;
            }
            else {
                // autodetect file type
                let ext = fileName.split('.');
                    ext = ext[ext.length - 1];

                for (let key in fileTypeExtensions) {
                    if (fileTypeExtensions.hasOwnProperty(key)) {
                        let extList = fileTypeExtensions[key];

                        if (extList.indexOf(ext) >= 0) {
                            fileType = key;
                            break;
                        }
                    }
                }

                if (fileType) {
                    fileString = fileName + ':' + fileType;
                    fileTypeString = fileType;
                }
                else {
                    fileString = fileName;
                    fileTypeString = 'normal';
                }
            }

            if (fileTypeString !== 'normal' && supportedVersioningTypes.indexOf(fileTypeString) < 0) {
                print('The versioning type: ' + fileTypeString + 'is unknown -> file skipped', 'strongWarning', 'date');
            }
            else {
                if (fs.existsSync(fileName)) {
                    let isInFileList = findFileInList(fileName);

                    if (isInFileList < 0) {
                        if (!modified) {
                            modified = true;
                        }

                        filesList.push(fileString);
                        print('file ' + fileName + ' added to list, type of file: ' + fileTypeString, 'completed', 'date');
                    }
                    else {
                        let oldFileType = configuration.filesList[isInFileList].split(':')[1];

                        if (oldFileType !== fileType) {
                            if (!modified) {
                                modified = true;
                            }

                            filesList[isInFileList] = fileString;
                            print('file ' + fileName + ' is already in list but the type has been changed to: ' + fileTypeString, 'completed', 'date');
                        }
                        else {
                            print('file ' + fileName + ' is already in versionFilesList.json with same type -> discarded', 'msgWarning', 'date');
                        }
                    }
                }
                else {
                    print('file ' + a[0] + ' does not exists -> discarded', 'msgWarning', 'date');
                }
            }
        });
    }

    //manage removals
    if (removes) {
        console.log('');
        let remArray = removes.split(',');

        remArray.forEach(function(r, index) {
            let isInFileList = findFileInList(r);

            if (isInFileList >= 0) {
                if (!modified) {
                    modified = true;
                }

                filesList.splice(isInFileList, 1);
                print('file ' + r + ' removed from list', 'completed', 'date');
            }
            else {
                print('file ' + r + ' is not in list -> nothing to remove', 'msgWarning', 'date');
            }
        });
    }

    if (modified) {
        configuration.filesList = filesList;

        fs.writeFileSync('./.versionFilesList.json', JSON.stringify(configuration, null, 2));
        print('.versionFilesList.json updated', 'completed', 'date');
    }

    process.exit(0);
}
570958
def update_data(self, index, data):
        

        datapack = self.built_embed.to_dict()["fields"][index]
        self.built_embed.set_field_at(index, name=datapack["name"], value=data, inline=datapack["inline"])
827196
def _update_srcmap_file(self, sources, overwrite=True):
        """"""

        if not os.path.isfile(self.files['srcmap']):
            return

        hdulist = fits.open(self.files['srcmap'])
        hdunames = [hdu.name.upper() for hdu in hdulist]

        srcmaps = {}

        for src in sources:

            if src.name.upper() in hdunames and not overwrite:
                continue
            self.logger.debug('Creating source map for %s', src.name)
            srcmaps[src.name] = self._create_srcmap(src.name, src)

        if srcmaps:
            self.logger.debug(
                'Updating source map file for component %s.', self.name)
            srcmap_utils.update_source_maps(self.files['srcmap'], srcmaps,
                                            logger=self.logger)
        hdulist.close()
661062
def _updateKW(image, filename, exten, skyKW, Value):
    """"""
    # Update the value in memory
    image.header[skyKW] = Value

    # Now update the value on disk
    if isinstance(exten,tuple):
        strexten = '[%s,%s]'%(exten[0],str(exten[1]))
    else:
        strexten = '[%s]'%(exten)
    log.info('Updating keyword %s in %s' % (skyKW, filename + strexten))
    fobj = fileutil.openImage(filename, mode='update', memmap=False)
    fobj[exten].header[skyKW] = (Value, 'Sky value computed by AstroDrizzle')
    fobj.close()
1283467
protected void updateFromResource() {

        setCreationDate(m_resource.getDateCreated());
        int length = m_resource.getLength();
        if (m_resource.isFolder()) {
            length = 1;
        }
        setFileSize(length);
        setModifyDate(m_resource.getDateLastModified());
        setAttributes(m_resource.isFile() ? FileAttribute.Normal : FileAttribute.Directory);
    }
948450
def update_coefs(self):
        """"""
        coefs = []
        sum_coefs = 0.
        moment1 = self.iuh.moment1
        for t in itertools.count(0., 1.):
            points = (moment1 % 1,) if t <= moment1 <= (t+2.) else ()
            try:
                coef = integrate.quad(
                    self._quad, 0., 1., args=(t,), points=points)[0]
            except integrate.IntegrationWarning:
                idx = int(moment1)
                coefs = numpy.zeros(idx+2, dtype=float)
                weight = (moment1-idx)
                coefs[idx] = (1.-weight)
                coefs[idx+1] = weight
                self.coefs = coefs
                warnings.warn(
                    'During the determination of the MA coefficients '
                    'corresponding to the instantaneous unit hydrograph '
                    '`%s` a numerical integration problem occurred.  '
                    'Please check the calculated coefficients: %s.'
                    % (repr(self.iuh), objecttools.repr_values(coefs)))
                break   # pragma: no cover
            sum_coefs += coef
            if (sum_coefs > .9) and (coef < self.smallest_coeff):
                coefs = numpy.array(coefs)
                coefs /= numpy.sum(coefs)
                self.coefs = coefs
                break
            else:
                coefs.append(coef)
954185
private boolean updateTrgPic(int index) {
		SubPicture picSrc = subtitleStream.getSubPicture(index);
		SubPicture picTrg = subPictures[index];
		double scaleX = (double) picTrg.getWidth() / picSrc.getWidth();
		double scaleY = (double) picTrg.getHeight() / picSrc.getHeight();
		double fx;
		double fy;
		if (configuration.getApplyFreeScale()) {
			fx = configuration.getFreeScaleFactorX();
			fy = configuration.getFreeScaleFactorY();
		} else {
			fx = 1.0;
			fy = 1.0;
		}

		int wOld = picTrg.getImageWidth();
		int hOld = picTrg.getImageHeight();
		int wNew = (int) (picSrc.getImageWidth() * scaleX * fx + 0.5);
		if (wNew < MIN_IMAGE_DIMENSION) {
			wNew = picSrc.getImageWidth();
		} else if (wNew > picTrg.getWidth()) {
			wNew = picTrg.getWidth();
		}
		int hNew = (int) (picSrc.getImageHeight() * scaleY * fy + 0.5);
		if (hNew < MIN_IMAGE_DIMENSION) {
			hNew = picSrc.getImageHeight();
		} else if (hNew > picTrg.getHeight()) {
			hNew = picTrg.getHeight();
		}
		picTrg.setImageWidth(wNew);
		picTrg.setImageHeight(hNew);
		if (wNew != wOld) {
			int xOfs = (int) (picSrc.getXOffset() * scaleX + 0.5);
			int spaceSrc = (int) ((picSrc.getWidth() - picSrc.getImageWidth())
					* scaleX + 0.5);
			int spaceTrg = picTrg.getWidth() - wNew;
			xOfs += (spaceTrg - spaceSrc) / 2;
			if (xOfs < 0) {
				xOfs = 0;
			} else if (xOfs + wNew > picTrg.getWidth()) {
				xOfs = picTrg.getWidth() - wNew;
			}
			picTrg.setOfsX(xOfs);
		}
		if (hNew != hOld) {
			int yOfs = (int) (picSrc.getYOffset() * scaleY + 0.5);
			int spaceSrc = (int) ((picSrc.getHeight() - picSrc.getImageHeight())
					* scaleY + 0.5);
			int spaceTrg = picTrg.getHeight() - hNew;
			yOfs += (spaceTrg - spaceSrc) / 2;
			if (yOfs + hNew > picTrg.getHeight()) {
				yOfs = picTrg.getHeight() - hNew;
			}
			picTrg.setOfsY(yOfs);
		}
		// was image cropped?
		return (wNew != wOld) || (hNew != hOld);
	}
586016
def UpdateParameters(Overwrite=False):
	'''
	
	
	'''
	

	print('This process may take a while, please be patient')
	time.sleep(1.0)
	
	
	#Download Tsyganenko data
	_DownloadTS05Data(Overwrite)
	
	#Download Kp Index data
	kp.UpdateLocalData()
	
	#list the files
	tabdir = Globals.DataPath+'tab/'
	if not os.path.isdir(tabdir):
		os.system('mkdir -pv '+tabdir)
	files = os.listdir(tabdir)
	nf = np.size(files)
	Years = 1995 + np.arange(nf)
	
	#read in Tsyganenko tab files
	tabs = []
	for i in range(0,nf):
		print('\rReading Year {:04d}'.format(Years[i]),end='')
		tabs.append(_ReadTab(Years[i]))
	print()
	
	#combine to one recarray
	print('Combining Yearly Data...') 
	n = 0
	for i in range(0,nf):
		n += tabs[i].size
	data = np.recarray(n,dtype=tabs[0].dtype)
	
	p = 0
	for i in range(0,nf):
		data[p:p+tabs[i].size] = tabs[i]
		p += tabs[i].size

	#get Kp indices
	udate = np.unique(data.Date)
	nu = np.size(udate)
	for i in range(0,nu):
		print('\rFinding Kp Index {:6.2f}%'.format(100.0*(i+1)/nu),end='')
		use = np.where(data.Date == udate[i])[0]
		k = kp.GetKp(udate[i])
		if k.size > 0:
			kind = np.int32(data.ut[use]/3.0)
			data.Kp[use] = k.Kp[kind]
		else:
			data.Kp[use] = 1
	print()
	
	#get G1 and G2
	for i in range(0,n):
		print('\rCalculating G param {0} of {1}'.format(i+1,n),end='')
		i0 = np.max([0,i-11])
		i1 = i + 1
		
		tmp = data[i0:i1]
		use = np.where(np.isfinite(tmp.By) & np.isfinite(tmp.Bz) & (tmp.IMFFlag > -1) & (tmp.ISWFlag > -1))[0]
		if use.size > 0:
			CA = np.arctan2(-tmp.By,tmp.Bz)
			Bp = np.sqrt(tmp.By**2 + tmp.Bz**2)
			Bs = np.abs(tmp.Bz)
			pos = np.where(tmp.Bz > 0)[0]
			Bs[pos] = 0.0
			h = ((Bp/40.0)**2)/(1.0 + Bp/40.0)
			data.G1[i] = np.sum(400.0*h*(np.sin(CA/2))**3)/use.size
			data.G2[i] = 0.005*np.sum(400.0*Bs)/use.size
		else:
			data.G1[i] = 0.0
			data.G2[i] = 0.0		
	
	print()
	
	#save the data
	fname = Globals.DataPath+'TSdata.bin'
	RT.SaveRecarray(data,fname)
713976
def file_renamed_in_data_in_editorstack(self, editorstack_id_str,
                                            original_filename, filename):
        """"""
        for editorstack in self.editorstacks:
            if str(id(editorstack)) != editorstack_id_str:
                editorstack.rename_in_data(original_filename, filename)
302780
def update(oldrev=nil, newrev=nil)
      if index_file_exists? && oldrev != "0"*40
        hg([
            "log --debug -r ?:? --style ? >> ?",
            oldrev, newrev, Style.file_index, path
          ])
      else
        hg(["log --debug -r : --style ? > ?", Style.file_index, path])
      end
    end
685865
def update(self, fname):
        
        ltfh = FileHandler(fname)
        self._log.addHandler(ltfh)
1203211
def assign_stream_id_raster(stream_file, subbasin_file, out_stream_file):
        
        stream_raster = RasterUtilClass.read_raster(stream_file)
        stream_data = stream_raster.data
        nrows = stream_raster.nRows
        ncols = stream_raster.nCols
        nodata = stream_raster.noDataValue
        subbain_data = RasterUtilClass.read_raster(subbasin_file).data
        nodata_array = ones((nrows, ncols)) * DEFAULT_NODATA
        newstream_data = where((stream_data > 0) & (stream_data != nodata),
                               subbain_data, nodata_array)
        RasterUtilClass.write_gtiff_file(out_stream_file, nrows, ncols, newstream_data,
                                         stream_raster.geotrans, stream_raster.srs,
                                         DEFAULT_NODATA, GDT_Int16)
686109
def update_file(finfo, sample_info, config):
    
    ffinal = filesystem.update_file(finfo, sample_info, config, pass_uptodate=True)

    _upload_dir_icommands_cli(config.get("dir"), config.get("folder"), config)