def write(self, *args, **kwargs): """Write a gridded N-dimensional data object out in specified format. This function provides the `~.NDDataBase` interface to the astropy unified I/O layer. This allows easily writing a file in the supported data formats. """ io_registry.write(self, *args, **kwargs)
def write(self, *args, **kwargs): """ Write a gridded N-dimensional data object out in specified format. This function provides the NDDataBase interface to the astropy unified I/O layer. This allows easily writing a file in the supported data formats. """ io_registry.write(self, *args, **kwargs)
def write(self, target, *args, **kwargs): """Write this table to a file Parameters ---------- target: `str` filename for output data file *args other positional arguments will be passed directly to the underlying writer method for the given format format : `str`, optional format for output data; if not given, an attempt will be made to automatically identify the format based on the `target` filename **kwargs other keyword arguments will be passed directly to the underlying writer method for the given format Raises ------ astropy.io.registry.IORegistryError if the `format` cannot be automatically identified Notes -----""" return registry.write(self, target, *args, **kwargs)
def write(self, target, *args, **kwargs): """Write this table to a file Parameters ---------- target: `str` filename for output data file *args other positional arguments will be passed directly to the underlying writer method for the given format format : `str`, optional format for output data; if not given, an attempt will be made to automatically identify the format based on the `target` filename **kwargs other keyword arguments will be passed directly to the underlying writer method for the given format Raises ------ astropy.io.registry.IORegistryError if the `format` cannot be automatically identified Notes -----""" return registry.write(self, target, *args, **kwargs)
def write(self, target, *args, **kwargs): """Write the `StarField` table to a file This utility is essentially a wrapper around `~astropy.table.Table.write`, see that method for more information Parameters ---------- target : `str` filename for output data file *args : `tuple`, optional other positional arguments passed to the underlying data writer for the given format format : `str`, optional file format for output data; if not given, the data writer will attempt to automatically identify the format based on ``target`` **kwargs : `dict`, optional other keyword arguments passed to the underlying data writer for the given format Notes -----""" return registry.write(self.table, target, *args, **kwargs)
def write(self, target, *args, **kwargs): """Write this `StateVector` to a file Parameters ---------- target : `str` output filename Notes -----""" return io_registry.write(self, target, *args, **kwargs)
def write(self, target, *args, **kwargs): """Write this `SegmentList` to a file Arguments and keywords depend on the output format, see the online documentation for full details for each format. Parameters ---------- target : `str` output filename Notes -----""" return io_registry.write(self, target, *args, **kwargs)
def write(self, target, *args, **kwargs): """Write this `SegmentList` to a file Arguments and keywords depend on the output format, see the online documentation for full details for each format. Parameters ---------- target : `str` output filename Notes -----""" return io_registry.write(self, target, *args, **kwargs)
def write(self, target, *args, **kwargs): """Write this `FrequencySeries` to a file Arguments and keywords depend on the output format, see the online documentation for full details for each format, the parameters below are common to most formats. Parameters ---------- target : `str` output filename format : `str`, optional output format identifier. If not given, the format will be detected if possible. See below for list of acceptable formats. Notes -----""" return io_registry.write(self, target, *args, **kwargs)
def write(self, target, *args, **kwargs): """Write this `SpectralVariance` to a file Arguments and keywords depend on the output format, see the online documentation for full details for each format, the parameters below are common to most formats. Parameters ---------- target : `str` output filename format : `str`, optional output format identifier. If not given, the format will be detected if possible. See below for list of acceptable formats. Notes -----""" return io_registry.write(self, target, *args, **kwargs)
print('fitting ' + str(prior.nsrc) + ' sources \n') print('using ' + str(prior.snpix) + ' pixels') from xidplus.numpyro_fit import LOFAR150 fit = LOFAR150.LOFAR_150(prior, num_samples=1000, num_warmup=1000) samples = fit.get_samples()['src_f'] posterior = xidplus.posterior_numpyro(fit, [prior]) if os.path.exists( 'data/xidplus_results/pybdsf/xidplus_run_{}'.format(n)) == True: () else: os.mkdir('data/xidplus_results/pybdsf/xidplus_run_{}'.format(n)) xidplus.save( [prior], posterior, 'data/xidplus_results/pybdsf/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.pkl' .format(n, n)) LOFAR_cat = cat.create_LOFAR_cat(posterior, prior, 0) LOFAR_cat = Table.read(LOFAR_cat) with serialize_method_as(LOFAR_cat, None): registry.write( LOFAR_cat, 'data/xidplus_results/pybdsf/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.fits' .format(n, n), format='fits', overwrite=True)
def __call__(self, *args, **kwargs): serialize_method = kwargs.pop('serialize_method', None) instance = self._instance with serialize_method_as(instance, serialize_method): registry.write(instance, *args, **kwargs)
def __call__(self, *args, serialize_method=None, **kwargs): instance = self._instance with serialize_method_as(instance, serialize_method): registry.write(instance, *args, **kwargs)
posterior = xidplus.posterior_stan(fit, [prior250, prior350, prior500]) priors = [prior250, prior350, prior500] import xidplus.catalogue as cat SPIRE_cat = cat.create_SPIRE_cat(posterior, priors[0], priors[1], priors[2]) SPIRE_cat = Table.read(SPIRE_cat) mask = [SPIRE_cat['HELP_ID'][i] in ids for i in range(len(SPIRE_cat))] SPIRE_cat = SPIRE_cat[mask] if os.path.exists('data/fir/v0_7/SPIRE/xidplus_run_{}'.format(taskid)) == True: () else: os.mkdir('data/fir/v0_7/SPIRE/xidplus_run_{}'.format(taskid)) xidplus.save([prior250, prior350, prior500], posterior, 'data/fir/v0_7/SPIRE/xidplus_run_{}/lofar_xidplus_fir_{}'.format( taskid, taskid)) #the next couple of lines are an alternative way to save astropy table since the Table.write method is currently broken with serialize_method_as(SPIRE_cat, None): registry.write( SPIRE_cat, 'data/fir/v0_7/SPIRE/xidplus_run_{}/lofar_xidplus_fir_{}.fits'.format( taskid, taskid), format='fits', overwrite=True) #Table.write(SPIRE_cat,'data/fir/v0_7/SPIRE/xidplus_run_{}/lofar_xidplus_fir_{}.fits'.format(taskid,taskid),overwrite=True) time1 = time.time() print('total time taken = {}'.format(time1 - time0))
def __call__(self, *args, serialize_method=None, **kwargs): registry.write(self._instance, *args, **kwargs)
def __call__(self, format, *args, **kwargs): return io_registry.write(self._instance, None, *args, format=format, **kwargs)
posterior = xidplus.posterior_stan(fit, [prior100, prior160]) priors = [prior100, prior160] import xidplus.catalogue as cat PACS_cat = cat.create_PACS_cat(posterior, priors[0], priors[1]) PACS_cat = Table.read(PACS_cat) mask = [PACS_cat['help_id'][i] in ids for i in range(len(PACS_cat))] PACS_cat = PACS_cat[mask] if os.path.exists( 'data/fir/PACS_no_lofar/xidplus_run_{}'.format(taskid)) == True: () else: os.mkdir('data/fir/PACS_no_lofar/xidplus_run_{}'.format(taskid)) xidplus.save( [prior100, prior160], posterior, 'data/fir/PACS_no_lofar/xidplus_run_{}/lofar_xidplus_fir_{}'.format( taskid, taskid)) #the next couple of lines are an alternative way to save astropy table since the Table.write method is currently broken with serialize_method_as(PACS_cat, None): registry.write( PACS_cat, 'data/fir/PACS_no_lofar/xidplus_run_{}/lofar_xidplus_fir_{}.fits'. format(taskid, taskid), format='fits', overwrite=True) #Table.write(PACS_cat,'data/fir/PACS/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.fits'.format(taskid,taskid),overwrite=True)
else: prfs.append(psf_dirty[0]) pinds.append(np.arange(0,prfs[m].shape[0],1)) prior.set_prfs(prfs,pinds,pinds) prior.get_pointing_matrix_multiple_prf() prior.upper_lim_map() print('fitting '+ str(prior.nsrc)+' sources \n') print('using ' + str(prior.snpix) + ' pixels') from xidplus.numpyro_fit import LOFAR150 fit=LOFAR150.LOFAR_150(prior,num_samples=1000,num_warmup=1000) samples = fit.get_samples()['src_f'] posterior = xidplus.posterior_numpyro(fit,[prior]) if os.path.exists('data/xidplus_results/random_positions/xidplus_run_{}'.format(n))==True:() else: os.mkdir('data/xidplus_results/random_positions/xidplus_run_{}'.format(n)) xidplus.save([prior],posterior,'data/xidplus_results/random_positions/xidplus_run_{}/random_positions_{}.pkl'.format(n,n)) LOFAR_cat=cat.create_LOFAR_cat(posterior,prior) LOFAR_cat = Table.read(LOFAR_cat) with serialize_method_as(LOFAR_cat, None): registry.write(LOFAR_cat,'data/xidplus_results/random_positions/xidplus_run_{}/random_positions_cat_{}.fits'.format(n,n),format='fits',overwrite=True)
def write(self, target, *args, **kwargs): """Write a `ChannelList` to a file Notes -----""" return io_registry.write(self, target, *args, **kwargs)
def __call__(self, *args, **kwargs): registry.write(self._instance, *args, **kwargs)
prior500.upper_lim_map() print('fitting '+ str(prior250.nsrc)+' sources \n') print('using ' + str(prior250.snpix)+', '+ str(prior350.snpix)+' and '+ str(prior500.snpix)+' pixels') from xidplus.stan_fit import SPIRE fit=SPIRE.all_bands(prior250,prior350,prior500,iter=1000) posterior=xidplus.posterior_stan(fit,[prior250,prior350,prior500]) priors = [prior250,prior350,prior500] import xidplus.catalogue as cat SPIRE_cat=cat.create_SPIRE_cat(posterior,priors[0],priors[1],priors[2]) SPIRE_cat = Table.read(SPIRE_cat) #mask = ['ILTJ' in SPIRE_cat['HELP_ID'][i] for i in range(len(SPIRE_cat)) if SPIRE_cat['RA'][i] in ras] mask = [SPIRE_cat['HELP_ID'][i] in ids for i in range(len(SPIRE_cat))] SPIRE_cat = SPIRE_cat[mask] if os.path.exists('data/fir/SPIRE_no_lofar/xidplus_run_{}'.format(taskid))==True:() else: os.mkdir('data/fir/SPIRE_no_lofar/xidplus_run_{}'.format(taskid)) xidplus.save([prior250,prior350,prior500],posterior,'data/fir/SPIRE_no_lofar/xidplus_run_{}/lofar_xidplus_fir_{}_rerun'.format(taskid,taskid)) #the next couple of lines are an alternative way to save astropy table since the Table.write method is currently broken with serialize_method_as(SPIRE_cat, None): registry.write(SPIRE_cat,'data/fir/SPIRE_no_lofar/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.fits'.format(taskid,taskid),format='fits') #Table.write(SPIRE_cat,'data/fir/SPIRE/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.fits'.format(taskid,taskid),format='fits',overwrite=True)
def write(self, target, *args, **kwargs): """Write a `ChannelList` to a file Notes -----""" return io_registry.write(self, target, *args, **kwargs)
else: prfs.append(psf_dirty[0]) pinds.append(np.arange(0,prfs[m].shape[0],1)) prior.set_prfs(prfs,pinds,pinds) prior.get_pointing_matrix_multiple_prf() prior.upper_lim_map() print('fitting '+ str(prior.nsrc)+' sources \n') print('using ' + str(prior.snpix) + ' pixels') from xidplus.numpyro_fit import LOFAR150 fit=LOFAR150.LOFAR_150(prior,num_samples=1000,num_warmup=1000) samples = fit.get_samples()['src_f'] posterior = xidplus.posterior_numpyro(fit,[prior]) if os.path.exists('data/xidplus_results/injected_sources/xidplus_run_{}'.format(n))==True:() else: os.mkdir('data/xidplus_results/injected_sources/xidplus_run_{}'.format(n)) xidplus.save([prior],posterior,'data/xidplus_results/injected_sources/xidplus_run_{}/injected_sources_{}.pkl'.format(n,n)) LOFAR_cat=cat.create_LOFAR_cat(posterior,prior) LOFAR_cat = Table.read(LOFAR_cat) with serialize_method_as(LOFAR_cat, None): registry.write(LOFAR_cat,'data/xidplus_results/injected_sources/xidplus_run_{}/injected_sources_cat_{}.fits'.format(n,n),format='fits',overwrite=True)
def write(self, target, *args, **kwargs): """Write this `DataQualityFlag` to file Notes -----""" return io_registry.write(self, target, *args, **kwargs)
def __call__(self, *args, **kwargs): registry.write(self._instance, *args, **kwargs)
posterior = xidplus.posterior_stan(fit, [prior250]) priors = [prior250] import xidplus.catalogue as cat MIPS_cat = cat.create_MIPS_cat(posterior, priors[0], 0) MIPS_cat = Table.read(MIPS_cat) mask = [MIPS_cat['help_id'][i] in ids for i in range(len(MIPS_cat))] MIPS_cat = MIPS_cat[mask] if os.path.exists('data/fir/v0_7/MIPS/xidplus_run_{}'.format(taskid)) == True: () else: os.mkdir('data/fir/v0_7/MIPS/xidplus_run_{}'.format(taskid)) #the next couple of lines are an alternative way to save astropy table since the Table.write method is currently broken with serialize_method_as(MIPS_cat, None): registry.write( MIPS_cat, 'data/fir/v0_7/MIPS/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.fits'. format(taskid, taskid), format='fits', overwrite=True) #Table.write(MIPS_cat,'data/fir/MIPS/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.fits'.format(taskid,taskid),overwrite=True) xidplus.save( [prior250], posterior, 'data/fir/v0_7/MIPS/xidplus_run_{}/lofar_xidplus_fir_{}_rerun.pkl'.format( taskid, taskid))
print('fitting ' + str(prior.nsrc) + ' sources \n') print('using ' + str(prior.snpix) + ' pixels') from xidplus.numpyro_fit import LOFAR150 fit = LOFAR150.LOFAR_150(prior, num_samples=1000, num_warmup=1000) samples = fit.get_samples()['src_f'] posterior = xidplus.posterior_numpyro(fit, [prior]) if os.path.exists( 'data/xidplus_results/pybdsf_components/xidplus_run_{}'.format( n)) == True: () else: os.mkdir('data/xidplus_results/pybdsf_components/xidplus_run_{}'.format(n)) xidplus.save( [prior], posterior, 'data/xidplus_results/pybdsf_components/xidplus_run_{}/LOFAR_{}_run_components_restoring_beam.pkl' .format(n, n)) LOFAR_cat = cat.create_LOFAR_cat(posterior, prior) LOFAR_cat = Table.read(LOFAR_cat) with serialize_method_as(LOFAR_cat, None): registry.write( LOFAR_cat, 'data/xidplus_results/pybdsf_components/xidplus_run_{}/LOFAR_{}_run_components_restoring_beam' .format(n, n), format='fits', overwrite=True)