astronomaly.feature_extraction package¶
Submodules¶
astronomaly.feature_extraction.autoencoder module¶
-
class
astronomaly.feature_extraction.autoencoder.Autoencoder(model_file='')¶ Bases:
object-
compile_autoencoder_model(input_image_shape)¶ Compiles the default autoencoder model. Note this model is designed to operate on 128x128 images. While it can run on different size images this can dramatically change the size of the final feature space.
Parameters: input_image_shape (tuple) – The expected shape of the input images. Can either be length 2 or 3 (to include number of channels).
-
encode(images)¶ Returns the deep encoded features for an array of images.
Parameters: images (np.ndarray) – Input images (nobjects x image_shape). For a single image, provide [image] as an array is expected. Returns: Deep features (nobjects x nfeatures) Return type: np.ndarray
-
fit(training_data, batch_size=32, epochs=10)¶ Actually train the autoencoder.
Parameters: - training_data (np.ndarray, list) – Either array or list of images. It’s recommended that this data be augmented with translation or rotation (or both).
- batch_size (int, optional) – Number of samples used to update weights in each iteration. A larger batch size can be more accurate but requires more memory and is slower to train.
- epochs (int, optional) – Number of full passes through the entire training set.
-
save(filename)¶ Saves Keras model in HDF5 format
Parameters: filename (string) – Location for saved model
-
-
class
astronomaly.feature_extraction.autoencoder.AutoencoderFeatures(training_dataset=None, retrain=False, **kwargs)¶
astronomaly.feature_extraction.feets_features module¶
astronomaly.feature_extraction.flatten_features module¶
-
class
astronomaly.feature_extraction.flatten_features.Flatten_Features(**kwargs)¶
astronomaly.feature_extraction.flux_histogram module¶
astronomaly.feature_extraction.photutils_features module¶
astronomaly.feature_extraction.power_spectrum module¶
-
class
astronomaly.feature_extraction.power_spectrum.PSD_Features(nbins='auto', **kwargs)¶
-
astronomaly.feature_extraction.power_spectrum.psd_2d(img, nbins)¶ Computes the power spectral density for an input image. Translation and rotation invariate features.
Parameters: - img (np.ndarray) – Input image
- nbins (int) – Number of frequency bins to use. Frequency will range from 1 pixel to the largest axis of the input image, measured in pixels.
Returns: Power spectral density at each frequency
Return type: np.ndarray
astronomaly.feature_extraction.shape_features module¶
astronomaly.feature_extraction.wavelet_features module¶
-
class
astronomaly.feature_extraction.wavelet_features.WaveletFeatures(level=2, wavelet_family='sym2', **kwargs)¶
-
astronomaly.feature_extraction.wavelet_features.flatten_swt2_coefficients(wavelet_coeffs)¶ A standardised way of flattening the swt2d coefficients They are stored as n_levels -> (cA, (cH, cV, cD)) where each of the sets of coeffcients has a list of [npixels, npixels]
Parameters: wavelet_coeffs (list) – Exactly as output by pywt Returns: - np.ndarray – Flattened coefficients
- labels – The labels of the coefficients
-
astronomaly.feature_extraction.wavelet_features.generate_labels(wavelet_coeffs)¶ Because the number of features may not be known till runtime, we can only create the labels of these features at runtime.
-
astronomaly.feature_extraction.wavelet_features.reshape_swt2_coefficients(flat_coeffs, nlev, image_shape)¶ Inverse function to restore a flattened array to pywt structure.
Parameters: Returns: pywt compatible coefficient structure
Return type:
-
astronomaly.feature_extraction.wavelet_features.wavelet_decomposition(img, level=2, wavelet_family='sym2')¶ Perform wavelet decomposition on single image
Parameters: - img (np.ndarray) – Image
- level (int, optional) – Level of depth for the wavelet transform
- wavelet_family (string or pywt.Wavelet object) – Which wavelet family to use
Returns: - np.ndarray – Flattened array of coefficients
- labels – The labels of the coefficients