def reconstruct_cfs2_model(): input_shape = (64, 64, 1) model = keras.Sequential( [ keras.Input(shape=input_shape), layers.Conv2D(32, kernel_size=(3, 3), activation="relu",name='conv1'), layers.BatchNormalization(name='norm1'), layers.MaxPooling2D(pool_size=(2, 2),name='maxpool1'), layers.Dropout(0.2,name='drop1'), layers.Conv2D(64, kernel_size=(3, 3), activation="relu",name='conv2'), layers.BatchNormalization(name='norm2'), layers.MaxPooling2D(pool_size=(2, 2),name='maxpool2'), layers.Flatten(name='flatten1'), layers.Dropout(0.5,name='drop2'), layers.Dense(3, activation="linear",name='dense_out'), ],name='seq_CNN' ) # Load the saved weights into the model model.load_weights('best_model_5000.h5') return modeldef reconstruct_cfs3_model(): input_shape = (64, 64, 1) model = keras.Sequential( [ keras.Input(shape=input_shape), layers.Conv2D(32, kernel_size=(3, 3), activation="relu",name='conv1'), layers.BatchNormalization(name='norm1'), layers.MaxPooling2D(pool_size=(2, 2),name='maxpool1'), layers.Dropout(0.2,name='drop1'), layers.Conv2D(64, kernel_size=(3, 3), activation="relu",name='conv2'), layers.BatchNormalization(name='norm2'), layers.MaxPooling2D(pool_size=(2, 2),name='maxpool2'), layers.Flatten(name='flatten1'), layers.Dropout(0.5,name='drop2'), layers.Dense(8, activation="linear",name='dense_out'), ],name='seq_CNN_cfs3' ) # Load the saved weights into the model model.load_weights('cfs3_best_model_5000.h5') return modeldef reconstruct_cfs4_model(): input_shape = (64, 64, 1) model = keras.Sequential( [ keras.Input(shape=input_shape), layers.Conv2D(32, kernel_size=(3, 3), activation="relu",name='conv1'), layers.BatchNormalization(name='norm1'), layers.MaxPooling2D(pool_size=(2, 2),name='maxpool1'), layers.Dropout(0.2,name='drop1'), layers.Conv2D(64, kernel_size=(3, 3), activation="relu",name='conv2'), layers.BatchNormalization(name='norm2'), layers.MaxPooling2D(pool_size=(2, 2),name='maxpool2'), layers.Flatten(name='flatten1'), layers.Dropout(0.5,name='drop2'), layers.Dense(15, activation="linear",name='dense_out'), ],name='seq_CNN_cfs4' ) # Load the saved weights into the model model.load_weights('cfs4_best_model_5000.h5') return model
obs_path='./obs_data_prep_for_testing/' test_img=np.load(obs_path+'dcdnb_hk0_box1.npy') plt.imshow(test_img,cmap='gray')
img=img/np.mean(img.flatten()) img_fix=smooth_compress(img, threshold = 2.8, gamma = 12.0, maskoutbragg=False) # thr=1.66, gam=20 threshold = 2.8, gamma = 12.0 zp=transform_log_obs(img_fix.flatten(),ut=0.0,mstd=1.0) get_univariate_analysis(np.log(zp)) img_fix=zp.reshape((64,-1)) fig, axes = plt.subplots(1, 3, figsize=(12,3)) ax1 = axes[0].imshow(img_fix, cmap='gray') ax2 = axes[1].hist(img_fix.flatten(), density=True, bins=64) ax3 = axes[2].hist(np.log(img_fix.flatten()+0.000001), density=True, bins=64) plt.tight_layout()corrf2=cfs2_model.predict(test_img)[0] corrf2=np.r_[1.0,corrf2].reshape((2,-1)) sns.heatmap(corrf2, cmap='bwr',annot=True)corrf3=cfs3_model.predict(test_img)[0] corrf3=np.r_[1.0,corrf3].reshape((3,-1)) sns.heatmap(corrf3, cmap='bwr',annot=True)
img=img/np.mean(img.flatten()) img_fix=smooth_compress(img, threshold = 1.8, gamma = 18.0, maskoutbragg=False) # thr=1.66, gam=20 threshold = 2.8, gamma = 12.0 zp=transform_log_obs(img_fix.flatten(),ut=0.0,mstd=1.0) get_univariate_analysis(np.log(zp)) img_fix=zp.reshape((64,-1)) fig, axes = plt.subplots(1, 3, figsize=(12,3)) ax1 = axes[0].imshow(img_fix, cmap='gray') ax2 = axes[1].hist(img_fix.flatten(), density=True, bins=64) ax3 = axes[2].hist(np.log(img_fix.flatten()+0.000001), density=True, bins=64) plt.tight_layout()test_img=np.expand_dims(img_fix, axis=(0,-1)) np.shape(test_img)