rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
parser.add_option("-s", "--snap", action="append", type="int", | parser.add_option("-S", "--snap", action="append", type="int", | def lsstSimMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="stor... |
parser.add_option("-c", "--sensor", action="append", | parser.add_option("-s", "--sensor", action="append", | def lsstSimMain(processFunction, outDatasetType, need=(), defaultRoot="."): parser = OptionParser() parser.add_option("-i", "--input", dest="root", default=defaultRoot, help="input root") parser.add_option("-o", "--output", dest="outRoot", default=".", help="output root") parser.add_option("-f", "--force", action="stor... |
'uCov,gCov,rCov,iCov,zCov,yCov', '-f', 'objectId,ra,dec,epoch']) | 'uCov,gCov,rCov,iCov,zCov,yCov', '-f', 'objectId,ra,decl,epoch']) | def referenceMatch(inputRoot, outputRoot, database, refCatalog, radius, tableSuffix=""): objectCsv = os.path.abspath(os.path.join(outputRoot, 'objDump.csv')) filtCsv = os.path.abspath(os.path.join(outputRoot, 'refFilt.csv')) matchCsv = os.path.abspath(os.path.join(outputRoot, 'refObjMatch.csv')) # Filter reference cata... |
for io in ["input", "output"]: policy.set("CrRejectStage.%sKeys.exposure" % io, policy.get("CrRejectStage.%sKeys.exposure" % io)) | def removeCRsSilently(self, exposure): """Remove CRs without trace""" mask = exposure.getMaskedImage().getMask() mask = mask.Factory(mask, True) # save initial mask | |
exposure = afwImage.ExposureF(filename, 0,bbox) | exposure = afwImage.ExposureF(filename, 0, bbox) exposure.setWcs(afwImage.makeWcs(exposure.getWcs().getFitsMetadata())) | def setUp(self): filename = os.path.join(eups.productDir("afwdata"), "CFHT", "D4", "cal-53535-i-797722_1") bbox = afwImage.BBox(afwImage.PointI(32,32), 512, 512) exposure = afwImage.ExposureF(filename, 0,bbox) |
butler: @butlerInput.paf | butler: @PT1Pipe/butlerInput.paf | def isrProcess(f): print >>f, """ appStage: { name: isrInputRaw parallelClass: lsst.pex.harness.IOStage.InputStageParallel eventTopic: None stagePolicy: { parameters: { butler: @butlerInput.paf inputItems: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): for snap in (0, 1): channelName = '"%d,%d"'... |
parameters: @ISR-flat.paf | parameters: @PT1Pipe/ISR-flat.paf | def isrProcess(f): print >>f, """ appStage: { name: isrInputRaw parallelClass: lsst.pex.harness.IOStage.InputStageParallel eventTopic: None stagePolicy: { parameters: { butler: @butlerInput.paf inputItems: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): for snap in (0, 1): channelName = '"%d,%d"'... |
parameters: @ISR-sdqaAmp.paf | parameters: @PT1Pipe/ISR-sdqaAmp.paf | def isrProcess(f): print >>f, """ appStage: { name: isrInputRaw parallelClass: lsst.pex.harness.IOStage.InputStageParallel eventTopic: None stagePolicy: { parameters: { butler: @butlerInput.paf inputItems: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): for snap in (0, 1): channelName = '"%d,%d"'... |
butler: @butlerUpdate.paf | butler: @PT1Pipe/butlerUpdate.paf | def isrProcess(f): print >>f, """ appStage: { name: isrInputRaw parallelClass: lsst.pex.harness.IOStage.InputStageParallel eventTopic: None stagePolicy: { parameters: { butler: @butlerInput.paf inputItems: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): for snap in (0, 1): channelName = '"%d,%d"'... |
parameters: @ISR-sdqaCcd.paf | parameters: @PT1Pipe/ISR-sdqaCcd.paf | def ccdAssemblyProcess(f): for snap in (0, 1): print >>f, """ appStage: { name: ccdAssemblyCcdList""" + str(snap) + """ parallelClass: lsst.datarel.ObjectListStageParallel eventTopic: None stagePolicy: { inputKeys: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): channelId = "%d%d" % (channelX, ch... |
butler: @butlerUpdate.paf | butler: @PT1Pipe/butlerUpdate.paf | def ccdAssemblyProcess(f): for snap in (0, 1): print >>f, """ appStage: { name: ccdAssemblyCcdList""" + str(snap) + """ parallelClass: lsst.datarel.ObjectListStageParallel eventTopic: None stagePolicy: { inputKeys: {""" for channelX in (0, 1): for channelY in (0, 1, 2, 3, 4, 5, 6, 7): channelId = "%d%d" % (channelX, ch... |
parameters: @CrSplit-backgroundEstimation.paf | parameters: @PT1Pipe/CrSplit-backgroundEstimation.paf | def crSplitProcess(f): print >>f, """ appStage: { name: crSplitBackgroundEstimation0 parallelClass: lsst.meas.pipeline.BackgroundEstimationStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: isrCcdExposure0 } outputKeys: { backgroundSubtractedExposure: bkgSubCcdExposure0 } parameters: @CrSplit-backgrou... |
parameters: @CrSplit-crReject.paf crRejectPolicy: @CrSplit-crReject-algorithm.paf | parameters: @PT1Pipe/CrSplit-crReject.paf crRejectPolicy: @PT1Pipe/CrSplit-crReject-algorithm.paf | def crSplitProcess(f): print >>f, """ appStage: { name: crSplitBackgroundEstimation0 parallelClass: lsst.meas.pipeline.BackgroundEstimationStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: isrCcdExposure0 } outputKeys: { backgroundSubtractedExposure: bkgSubCcdExposure0 } parameters: @CrSplit-backgrou... |
psfPolicy: @ImgChar-sourceDetect-psf.paf backgroundPolicy: @ImgChar-sourceDetect-background.paf | psfPolicy: @PT1Pipe/ImgChar-sourceDetect-psf.paf backgroundPolicy: @PT1Pipe/ImgChar-sourceDetect-background.paf | def imgCharProcess(f): print >>f, """ appStage: { name: icSourceDetect parallelClass: lsst.meas.pipeline.SourceDetectionStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: visitExposure } outputKeys: { positiveDetection: positiveFootprintSet negativeDetection: negativeFootprintSet psf: simplePsf } psfP... |
stagePolicy: @ImgChar-wcsDetermination.paf | stagePolicy: @PT1Pipe/ImgChar-wcsDetermination.paf | def imgCharProcess(f): print >>f, """ appStage: { name: icSourceDetect parallelClass: lsst.meas.pipeline.SourceDetectionStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: visitExposure } outputKeys: { positiveDetection: positiveFootprintSet negativeDetection: negativeFootprintSet psf: simplePsf } psfP... |
butler: @butlerUpdate.paf | butler: @PT1Pipe/butlerUpdate.paf | def imgCharProcess(f): print >>f, """ appStage: { name: icSourceDetect parallelClass: lsst.meas.pipeline.SourceDetectionStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: visitExposure } outputKeys: { positiveDetection: positiveFootprintSet negativeDetection: negativeFootprintSet psf: simplePsf } psfP... |
backgroundPolicy: @SFM-sourceDetect-background.paf | backgroundPolicy: @PT1Pipe/SFM-sourceDetect-background.paf | def sfmProcess(f): print >>f, """ appStage: { name: sfmSourceDetect parallelClass: lsst.meas.pipeline.SourceDetectionStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: scienceExposure psf: psf } outputKeys: { positiveDetection: positiveFootprintSet } backgroundPolicy: @SFM-sourceDetect-background.paf ... |
butler: @butlerUpdate.paf | butler: @PT1Pipe/butlerUpdate.paf | def sfmProcess(f): print >>f, """ appStage: { name: sfmSourceDetect parallelClass: lsst.meas.pipeline.SourceDetectionStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: scienceExposure psf: psf } outputKeys: { positiveDetection: positiveFootprintSet } backgroundPolicy: @SFM-sourceDetect-background.paf ... |
sql.createDb(database) sql.execScript(os.path.join(catDir, 'sql', 'lsstSchema4mysqlDC3b.sql')) | def main(): usage = dedent("""\ usage: %prog [options] <database> Program which creates an LSST run database and instantiates the LSST schema therein. Indexes on tables which will be loaded by the various datarel ingest scripts are disabled. Once loading has finished, the finishDb.py script should be run to re-enable ... | |
for tableName in ('BadSource', 'Source', 'Object'): | for tableName in ('BadSource', 'Source', 'Object', 'SimRefObject', 'RefObjMatch'): | def setupDb(database, tableSuffix=""): execStmt("CREATE DATABASE IF NOT EXISTS %s;" % database) for tableName in ('BadSource', 'Source', 'Object'): execStmt("CREATE TABLE %s.%s%s LIKE pt1_templates.%s" % (database, tableName, tableSuffix, tableName)) |
filename="/lsst/daues/ipac/add_ons/afwdata-ImSim/processed/imsim_85751839_R23_S11_C00_E000.fits" bbox = afwImage.BBox(afwImage.PointI(32,32), 512, 512) exposure = afwImage.ExposureF(filename, 0,bbox) | filename = os.path.join(eups.productDir("afwdata"), "ImSim", "postISR", "v85751839-fr", "s0", "R23", "S11", "C00.fits") bbox = afwImage.BBox(afwImage.PointI(0,0), 512, 512) exposure = afwImage.ExposureF(filename, 0, bbox) | def setUp(self): # filename = os.path.join(eups.productDir("afwdata"), "CFHT", "D4", "cal-53535-i-797722_1") |
exposure: visitim | def crSplitProcess(f): print >>f, """ appStage: { name: crSplitBackgroundEstimation0 parallelClass: lsst.meas.pipeline.BackgroundEstimationStageParallel eventTopic: None stagePolicy: { inputKeys: { exposure: isrCcdExposure0 } outputKeys: { backgroundSubtractedExposure: bkgSubCcdExposure0 } parameters: @CrSplit-backgrou... | |
num, cluster, password = station num = int(num) station_list[num] = (cluster, password) | if station: num, cluster, password = station num = int(num) station_list[num] = (cluster, password) | def do_init(configfile): """Load configuration and passwords and set up a logger handler This function will do one-time initialization. By using global variables, we eliminate the need to reread configuration and passwords on every request. """ # set up config global config try: config except NameError: config = Con... |
system = models.BooleanField(blank=True, null=True) | system = models.BooleanField(blank=True, default=False) | def get_protocol(self): return PROTOCOLS[str(self.protocol)] |
allow_express_pay = models.BooleanField(verbose_name=u'Оплата экспресс картами', blank=True, null=True, default=False) | allow_express_pay = models.BooleanField(verbose_name=u'Оплата экспресс картами', blank=True, default=False) | def __unicode__(self): return u"%s" % self.name |
database.flush() | def update(self, documents=None, after_index=None, per_page=10000, commit_each=False): """ Update the database with the documents. There are some default value and terms in a document: * Values: 1. Used to store the ID of the document 2. Store the model of the object (in the string format, like "project.app.model") 3. ... | |
def handle(self, verbose=False, make_daemon=False, timeout=10, | def handle(self, verbose=False, make_daemon=False, loop=False, timeout=10, | def handle(self, verbose=False, make_daemon=False, timeout=10, rebuild_index=False, per_page=1000, commit_each=False, *args, **options): utils.load_indexes() |
update_changes(verbose, timeout, not make_daemon, per_page, commit_each) | update_changes(verbose, timeout, not (loop or make_daemon), per_page, commit_each) | def handle(self, verbose=False, make_daemon=False, timeout=10, rebuild_index=False, per_page=1000, commit_each=False, *args, **options): utils.load_indexes() |
return list(self._clone(offset=k, limit=1))[k] | return iter(self._clone(offset=k, limit=1)).next() | def __getitem__(self, k): if not isinstance(k, (slice, int, long)): raise TypeError if not ((not isinstance(k, slice) and (k >= 0)) or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0))): raise IndexError, "Negative indexing is not supported." |
from djapian.tests.utils import WeightenedIndexerTest, WeightenedEntry | def test_result(self): self.assertEqual(len(self.result), 2) | |
print list(self._current_index.search(query)[self._parse_slice(_slice)]) | try: _slice = self._parse_slice(_slice) except ValueError: print 'Error: second argument must be slice' return print list(self._current_index.search(query)[_slice]) | def do_query(self, query, _slice=''): """ Returns objects fetched by given query """ print list(self._current_index.search(query)[self._parse_slice(_slice)]) |
print 'Illegal index alias `%s`. See `list` command for available aliases' % index | print 'Error: illegal index alias `%s`. See `list` command for available aliases' % index | def _get_indexer(self, index): try: _space, _model, _indexer = map(int, index.split('.')) |
def get_content_types(*actions): types = Change.objects.filter(action__in=actions)\ | def get_content_types(app_models, *actions): lookup_args = dict(action__in=actions) if app_models is not None: ct_list = [ContentType.objects.get_for_model(model) for model in app_models] lookup_args.update(dict(content_type__in=ct_list)) types = Change.objects.filter(models.Q(**lookup_args))\ | def get_content_types(*actions): types = Change.objects.filter(action__in=actions)\ .values_list('content_type', flat=True)\ .distinct() return ContentType.objects.filter(pk__in=types) |
def update_changes(verbose, timeout, once, per_page, commit_each): | def update_changes(verbose, timeout, once, per_page, commit_each, app_models=None): | def update_changes(verbose, timeout, once, per_page, commit_each): counter = [0] def reset_counter(): counter[0] = 0 def after_index(obj): counter[0] += 1 if verbose: sys.stdout.write('.') sys.stdout.flush() commiter = Commiter.create(commit_each)( lambda: None, transaction.commit, transaction.rollback ) while Tru... |
for ct in get_content_types('add', 'edit'): | for ct in get_content_types(app_models, 'add', 'edit'): | def after_index(obj): counter[0] += 1 |
for ct in get_content_types('delete'): | for ct in get_content_types(app_models, 'delete'): | def after_index(obj): counter[0] += 1 |
def rebuild(verbose, per_page, commit_each): | def rebuild(verbose, per_page, commit_each, app_models=None): | def rebuild(verbose, per_page, commit_each): def after_index(obj): if verbose: sys.stdout.write('.') sys.stdout.flush() for space in IndexSpace.instances: for model, indexers in space.get_indexers().iteritems(): for indexer in indexers: indexer.clear() indexer.update(None, after_index, per_page, commit_each) |
for indexer in indexers: indexer.clear() indexer.update(None, after_index, per_page, commit_each) | if app_models is None or model in app_models: for indexer in indexers: indexer.clear() indexer.update(None, after_index, per_page, commit_each) | def after_index(obj): if verbose: sys.stdout.write('.') sys.stdout.flush() |
make_option('--verbose', action='store_true', default=False, | make_option('--verbose', dest='verbose', default=False, action='store_true', | def after_index(obj): if verbose: sys.stdout.write('.') sys.stdout.flush() |
make_option('--time-out', dest='timeout', default=10, type='int', | make_option('--time-out', dest='timeout', default=10, action='store', type='int', | def after_index(obj): if verbose: sys.stdout.write('.') sys.stdout.flush() |
action='store', type=int, | action='store', type='int', | def after_index(obj): if verbose: sys.stdout.write('.') sys.stdout.flush() |
def handle(self, verbose=False, make_daemon=False, loop=False, timeout=10, rebuild_index=False, per_page=1000, commit_each=False, *args, **options): | def handle(self, *app_labels, **options): verbose = options['verbose'] make_daemon = options['make_daemon'] loop = options['loop'] timeout = options['timeout'] rebuild_index = options['rebuild_index'] per_page = options['per_page'] commit_each = options['commit_each'] | def handle(self, verbose=False, make_daemon=False, loop=False, timeout=10, rebuild_index=False, per_page=1000, commit_each=False, *args, **options): utils.load_indexes() |
if rebuild_index: rebuild(verbose, per_page, commit_each) | if app_labels: try: app_list = [models.get_app(app_label) for app_label in app_labels] except (ImproperlyConfigured, ImportError), e: raise CommandError("%s. Are you sure your INSTALLED_APPS setting is correct?" % e) for app in app_list: app_models = models.get_models(app, include_auto_created=True) if rebuild_index: r... | def handle(self, verbose=False, make_daemon=False, loop=False, timeout=10, rebuild_index=False, per_page=1000, commit_each=False, *args, **options): utils.load_indexes() |
update_changes(verbose, timeout, not (loop or make_daemon), per_page, commit_each) | if rebuild_index: rebuild(verbose, per_page, commit_each) else: update_changes(verbose, timeout, not (loop or make_daemon), per_page, commit_each) | def handle(self, verbose=False, make_daemon=False, loop=False, timeout=10, rebuild_index=False, per_page=1000, commit_each=False, *args, **options): utils.load_indexes() |
return value | return smart_str(value) | def convert(self, field_value): """ Generates index values (for sorting) for given field value and its content type """ if field_value is None: return None |
return u', '.join(map(smart_str, value)) | return ', '.join(map(smart_str, value)) | def resolve(self, value): bits = self.path.split(".") |
index_value = field.convert(value) if index_value is not None: doc.add_value(field.number, smart_str(index_value)) | doc.add_value(field.number, field.convert(value)) | def update(self, documents=None, after_index=None, per_page=10000, commit_each=False): """ Update the database with the documents. There are some default value and terms in a document: * Values: 1. Used to store the ID of the document 2. Store the model of the object (in the string format, like "project.app.model") 3. ... |
generator.index_text(smart_str(value), field.weight, prefix) | value = smart_str(value) generator.index_text(value, field.weight, prefix) | def update(self, documents=None, after_index=None, per_page=10000, commit_each=False): """ Update the database with the documents. There are some default value and terms in a document: * Values: 1. Used to store the ID of the document 2. Store the model of the object (in the string format, like "project.app.model") 3. ... |
generator.index_text(smart_str(value), field.weight) | generator.index_text(value, field.weight) | def update(self, documents=None, after_index=None, per_page=10000, commit_each=False): """ Update the database with the documents. There are some default value and terms in a document: * Values: 1. Used to store the ID of the document 2. Store the model of the object (in the string format, like "project.app.model") 3. ... |
doc = match.get_document() | doc = match.document | def _parse_results(self): self._resultset_cache = [] |
percent = match.get_percent() rank = match.get_rank() weight = match.get_weight() | percent = match.percent rank = match.rank weight = match.weight | def _parse_results(self): self._resultset_cache = [] |
collapse_count = match.get_collapse_count() or None collapse_key = match.get_collapse_key() or None | collapse_count = match.collapse_count or None collapse_key = match.collapse_key or None | def _parse_results(self): self._resultset_cache = [] |
value = u', '.join( | value = ', '.join( | def resolve(self, value): bits = self.path.split(".") |
assert ((not isinstance(k, slice) and (k >= 0)) | if not ((not isinstance(k, slice) and (k >= 0)) | def __getitem__(self, k): if not isinstance(k, (slice, int, long)): raise TypeError assert ((not isinstance(k, slice) and (k >= 0)) or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0))), \ "Negative indexing is not supported." |
and (k.stop is None or k.stop >= 0))), \ "Negative indexing is not supported." | and (k.stop is None or k.stop >= 0))): raise IndexError, "Negative indexing is not supported." | def __getitem__(self, k): if not isinstance(k, (slice, int, long)): raise TypeError assert ((not isinstance(k, slice) and (k >= 0)) or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0))), \ "Negative indexing is not supported." |
if indices_tally == 2: indices_tally = 0 | else: continue if indices_tally == 1: continue elif indices_tally == 2: | def read_pb_partitions(sampled_partitions_file, from_row=0, to_row=None, read_rates=True): site_indices_regex = r'^\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+\t\d+' site_indices_pattern = re.compile(site_indices_regex) posterior = PosteriorOfPartitions() line_iter = iter(sampled_partitions_file) indices_tally = 0 samp... |
if hasattr(self, 'pack'): del self.pack if hasattr(self, 'part'): del self.part | def teardown_class(cls): if hasattr(self, 'pack'): del self.pack if hasattr(self, 'part'): del self.part cls.remove_testfile() | |
part_edit(args.path) | part_edit(args.path, args.reformat_xml) | def part_edit_cmd(): 'Edit a part from an OOXML Package without unzipping it' parser = argparse.ArgumentParser(description=inspect.getdoc(part_edit_cmd)) parser.add_argument('path', help='Path to part (including path to zip file, i.e. ./file.zipx/part)') args = parser.parse_args() part_edit(args.path) |
def part_edit(path): | def part_edit(path, reformat_xml): | def part_edit(path): file, ipath = find_file(path) pkg = Package.from_file(file) part = pkg['/'+ipath] ef = EditableFile(part.dump()) ef.edit(ipath) if ef.changed: part.load(ef.data) pkg.save() |
ef = EditableFile(part.dump()) | data = part.dump() if reformat_xml: data = etree.tostring(etree.fromstring(data), pretty_print=True) ef = EditableFile(data) | def part_edit(path): file, ipath = find_file(path) pkg = Package.from_file(file) part = pkg['/'+ipath] ef = EditableFile(part.dump()) ef.edit(ipath) if ef.changed: part.load(ef.data) pkg.save() |
base, rname = posixpath.split(item.name) base = base[1:] | base, rname = posixpath.split(to_zip_name(item.name)) | def ropen(item): if isinstance(item, Relationships): return if isinstance(item, Part): base, rname = posixpath.split(item.name) base = base[1:] relname = posixpath.join(base, '_rels', '%s.rels' % rname) if relname in zf.namelist(): item._load_rels(zf.read(relname)) for rel in item.relationships: pname = posixpath.join(... |
data = "".join(self._get_matching_segments(rel.target)) | target_path = to_zip_name(pname) data = "".join(self._get_matching_segments(target_path)) | def ropen(item): if isinstance(item, Relationships): return if isinstance(item, Part): base, rname = posixpath.split(item.name) base = base[1:] relname = posixpath.join(base, '_rels', '%s.rels' % rname) if relname in zf.namelist(): item._load_rels(zf.read(relname)) for rel in item.relationships: pname = posixpath.join(... |
localtime = time.localtime(time.time()) | now = time.localtime(time.time()) ZipInfoNow = functools.partial(ZipInfo, date_time = now) | def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE... |
ct_info = ZipInfo('[Content_Types].xml', localtime) | ct_info = ZipInfoNow('[Content_Types].xml') | def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE... |
rel_info = ZipInfo('_rels/.rels', localtime) | rel_info = ZipInfoNow('_rels/.rels') | def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE... |
part_info = ZipInfo(name[1:], localtime) | part_info = ZipInfoNow(to_zip_name(name)) | def save(self, target=None): localtime = time.localtime(time.time()) zf = ZipFile(target or self.name, mode='w', compression=ZIP_DEFLATED) ct_info = ZipInfo('[Content_Types].xml', localtime) ct_info.create_system = SYSUNIX ct_info.flag_bits = 8 ct_info.external_attr = USER_READ_WRITE ct_info.compress_type = ZIP_DEFLATE... |
self.core_properties = None | def __init__(self): self.parts = {} self.base = '/' self.relationships = rels = Relationships(self, self) self[rels.name] = rels self.content_types = ContentTypes() self.content_types.add(ContentType.Default(rels.content_type, 'rels')) self.core_properties = None | |
assert ct.extension not in self.defaults | if ct.extension in self.defaults: assert self.defaults[ct.extension] == ct | def _validate_default(self, ct): assert ct.extension not in self.defaults return ct |
if elem and elem.text: | if elem is not None and elem.text: | def set_attr_if_tag(tag, attr=None, transform=identity): if attr is None: ns, attr = parse_tag(tag) elem = xml.find(tag) if elem and elem.text: value = transform(elem.text) setattr(self, attr, value) |
J.Mx = [49, 193, 769, 3073, 12289] | J.Mx = [49, 98, 196, 392, 784] | def define_refinement_paths(KSPRTOL, SSARTOL): # Define all the supported refinement paths: tests = {} # A A = PISMVerificationTest() A.name = "A" A.test = "isothermal SIA with a marine margin" A.path = "(refine dx=53.33,40,26.67,20,13.33,km, dx=dy and Mx=My=31,41,61,81,121)" A.Mx = [31, 41, 61, 81, 121] A.My = A.M... |
dt = np.diff(t[:],axis=0) | dt = np.diff(t[::stride],axis=0) | def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask... |
X = X[:] | X = X[::stride] | def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask... |
dXpdt = dX/dt | dXpdt = dXp/dt | def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask... |
mask = np.array(nc.variables['mask'][:]) | mask = np.array(nc.variables['mask'][::stride,:,:]) | def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask... |
X = np.ma.array(data=X[:],mask=mask2) | X = np.ma.array(data=X[::stride,:,:],mask=mask2) | def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask... |
X = np.array(X[:]) | X = np.array(X[::stride,:,:]) | def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask... |
plt.semilogy(t[1:],dVpdt, 'b', lw = 2) | plt.semilogy(t[1::stride],dVpdt, 'b', lw = 2) | def getRateOfChange(t,X,p,varname): # differenetiate time along time axis dt = np.diff(t[:],axis=0) Xdim = X.ndim Xunits = X.units if Xdim == 1: X = X[:] dXp = np.diff(X) dXpdt = dX/dt elif Xdim == 3: if 'mask' in nc.variables.keys(): mask = np.array(nc.variables['mask'][:]) # (t,y,x) k = np.nonzero((mask... |
pism_var = squeeze(nc_pism.variables[dovars[0]]) ref_var = squeeze(nc_reference.variables[dovars[1]]) | pism_var = squeeze(nc_pism.variables[dovars[0]][:]) ref_var = squeeze(nc_reference.variables[dovars[1]][:]) | def usagefailure(message): print message print print usage exit(2) |
thk_var = squeeze(nc_thk.variables["thk"]) | thk_var = squeeze(nc_thk.variables["thk"][:]) | def usagefailure(message): print message print print usage exit(2) |
print "Files are the same within given tolerance." | print "Files are the same within tolerance %.1e" % tol | def success(): print "Files are the same within given tolerance." exit(0) |
failure() | usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) | def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable. failure() try: delta = abs(var1 - var2).max() except: # This can happen if vari... |
failure() | usagefailure("ERROR: VARIABLE '%s' OF INCOMPATIBLE SHAPES (?) IN FILES" % name) | def compare_vars(nc1, nc2, name, tol): from numpy import squeeze # Find variables: try: var1 = squeeze(nc1.variables[name][:]) var2 = squeeze(nc2.variables[name][:]) except: # This can happen if one of the files does not have the variable. failure() try: delta = abs(var1 - var2).max() except: # This can happen if vari... |
failure() | usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file2) | def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v... |
opts, args = getopt(argv[1:], "t:v:x") tol = 0 | try: opts, args = getopt(argv[1:], "t:v:x", ["help","usage"]) except GetoptError: usagefailure('ERROR: INCORRECT COMMAND LINE ARGUMENTS FOR nccmp.py') | def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v... |
failure() | usagefailure('ERROR: WRONG NUMBER OF ARGUMENTS FOR nccmp.py') | def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') nc2 = NC(file2, 'r') except: # This can happen if one of the files could not be opened. failure() if (exclude == False): if len(v... |
nc.history += historystr | nc.history = historystr + nc.history | def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ... |
from shutil import copyfile, move | from shutil import copy, move | def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ... |
copyfile(input_filename, tmp_filename) | copy(input_filename, tmp_filename) | def laplace(data, mask, eps1, eps2, initial_guess='mean', max_iter=10000): """laplace solves the Laplace equation using the SOR method with Chebyshev acceleration as described in 'Numerical Recipes in Fortran: the art of scientific computing' by William H. Press et al -- 2nd edition, section 19.5. data is a 2-d array ... |
nccmp.py -x C foo.nc bar.nc compare all variables except C | nccmp.py -x -v C foo.nc bar.nc compare all variables except C | def failure(): print "Files are different." exit(1) |
from numpy import squeeze | from numpy import squeeze, isnan, ma | def compare_vars(nc1, nc2, name, tol): from numpy import squeeze try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: delta = abs(var1... |
delta = abs(var1 - var2).max() | mask = isnan(var1) | isnan(var2) | def compare_vars(nc1, nc2, name, tol): from numpy import squeeze try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: delta = abs(var1... |
print delta, denom | print "name = %s, delta = %e, denom = %e" % (name, delta, denom) | def compare_vars(nc1, nc2, name, tol, relative=False): from numpy import squeeze, isnan, ma try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % n... |
var[thk<thktol] = -9999.0 | if 't' in dims: for j in range(var.shape[0]): tmp = var[j] tmp[thk<thktol] = fill_value var[j] = tmp else: var[thk<thktol] = fill_value | def maskout(nc, thk, name, thktol=1.0): from numpy import squeeze, isnan, ma try: var = squeeze(nc.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE" % name) var[thk<thktol] = -9999.0 return var |
def success(): print "Files are the same within tolerance %.1e" % tol | def success(relative): if relative: print "Files are the same within relative tolerance %.1e" % tol else: print "Files are the same within tolerance %.1e" % tol | def success(): print "Files are the same within tolerance %.1e" % tol exit(0) |
def compare_vars(nc1, nc2, name, tol): | def compare_vars(nc1, nc2, name, tol, relative=False): | def compare_vars(nc1, nc2, name, tol): from numpy import squeeze, isnan, ma try: var1 = squeeze(nc1.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 1" % name) try: var2 = squeeze(nc2.variables[name][:]) except: usagefailure("ERROR: VARIABLE '%s' NOT FOUND IN FILE 2" % name) try: mask ... |
def compare(file1, file2, variables, exclude, tol): | def compare(file1, file2, variables, exclude, tol, relative): | def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO... |
compare_vars(nc1, nc2, each, tol) | compare_vars(nc1, nc2, each, tol, relative) | def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO... |
opts, args = getopt(argv[1:], "t:v:x", ["help","usage"]) | opts, args = getopt(argv[1:], "t:v:xr", ["help","usage"]) | def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO... |
compare(args[0],args[1], variables, exclude, tol) | compare(args[0],args[1], variables, exclude, tol, relative) | def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO... |
success() | success(relative) | def compare(file1, file2, variables, exclude, tol): try: from netCDF4 import Dataset as NC except: from netCDF3 import Dataset as NC from numpy import unique, r_ try: nc1 = NC(file1, 'r') except: usagefailure("ERROR: FILE '%s' CANNOT BE OPENED FOR READING" % file1) try: nc2 = NC(file2, 'r') except: usagefailure("ERRO... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.