Python Pandas: Adding FAST System Noise to Simulated Blurred Map
import pandas as pd import numpy as np
add FAST system noise on the blur map to simulate true observed map
sigma = 800 # \mu Jy, Standard Deviation of noise
read map
filepath = '/home/wangjiaxin/final/blurred/flux_blurred_all_gal_300f.hdf5' with pd.HDFStore(filepath, mode='r') as store: S_df = store['S'] xbin_df = store['x_bin_edge'] ybin_df = store['y_bin_edge'] fbin_df = store['nu_bin_edge']
add noise
noise = np.random.normal(0, sigma, S_df.shape) newdata = S_df + noise
save
output = '/home/dyliu/Filament/TNG_100/flux_blurred_all_gal_300f_800n.hdf5' with pd.HDFStore(output, mode='w') as store: store['S'] = newdata store['x_bin_edge'] = xbin_df store['y_bin_edge'] = ybin_df store['nu_bin_edge'] = fbin_df
This code addresses the 'cannot create a storer if the object is not existing nor a value are passed' error
by using the 'r' mode for reading and 'w' mode for writing to the HDFStore object.
原文地址: https://www.cveoy.top/t/topic/nesC 著作权归作者所有。请勿转载和采集!