diff --git a/scimes/orion2scimes.py b/scimes/orion2scimes.py index 68e22c5..5b558a6 100644 --- a/scimes/orion2scimes.py +++ b/scimes/orion2scimes.py @@ -4,6 +4,9 @@ import numpy as np import math import aplpy +import random + +from matplotlib import pyplot as plt from astrodendro import Dendrogram, ppv_catalog from astropy import units as u @@ -64,13 +67,13 @@ def make_asgn(dendro, data_file, cores_idx = [], tag = '_', collapse = True): # Making the assignment cube if len(data.shape) == 3: - asgn = np.zeros(data.shape, dtype = int32) + asgn = np.zeros(data.shape, dtype = np.int32) if len(data.shape) == 4: - asgn = np.zeros((data.shape[1],data.shape[2],data.shape[3]), dtype = int32) + asgn = np.zeros((data.shape[1],data.shape[2],data.shape[3]), dtype = np.int32) for i in cores_idx: - asgn[where(d[i].get_mask(shape = asgn.shape))] = i + asgn[np.where(d[i].get_mask(shape = asgn.shape))] = i # Write the fits file @@ -85,8 +88,8 @@ def make_asgn(dendro, data_file, cores_idx = [], tag = '_', collapse = True): asgn_map = np.amax(asgn.data, axis = 0) - matshow(asgn_map, origin = "lower") - colorbar() + plt.matshow(asgn_map, origin = "lower") + plt.colorbar() return @@ -95,13 +98,14 @@ def make_asgn(dendro, data_file, cores_idx = [], tag = '_', collapse = True): -path = '/Volumes/Zeruel_data/ORION/' +path = './' +#path = '/Volumes/Zeruel_data/ORION/' #path = '/Users/Dario/Documents/dendrograms/' -filename = path+'orion' +filename = os.path.join(path, 'orion') -do_make = False -do_catalog = False -do_load = False +do_make = True +do_catalog = True +do_load = True if do_make: @@ -115,7 +119,7 @@ def make_asgn(dendro, data_file, cores_idx = [], tag = '_', collapse = True): data = hdu.data hd = hdu.header - if size(shape(data))==4: + if data.ndim==4: data = data[0,:,:,:] diff --git a/scimes/scimes.py b/scimes/scimes.py index f20c6e9..19aa924 100644 --- a/scimes/scimes.py +++ b/scimes/scimes.py @@ -6,8 +6,13 @@ from matplotlib import pyplot as plt -from sklearn.cluster import spectral_clustering -from itertools import combinations +from astrodendro import Dendrogram, ppv_catalog +from astropy import units as u +from astropy.stats import median_absolute_deviation as mad + +from sklearn import metrics +from spectral import spectral_clustering +from skimage.measure import regionprops def mat_smooth(Mat, scalpar = 0, lscal = False): diff --git a/scimes/spectral.py b/scimes/spectral.py index 7c19a0d..f2d23c8 100644 --- a/scimes/spectral.py +++ b/scimes/spectral.py @@ -9,13 +9,13 @@ import numpy as np -from ..base import BaseEstimator, ClusterMixin -from ..utils import check_random_state, as_float_array, deprecated -from ..utils.extmath import norm -from ..metrics.pairwise import pairwise_kernels -from ..neighbors import kneighbors_graph -from ..manifold import spectral_embedding -from .k_means_ import k_means +from sklearn.base import BaseEstimator, ClusterMixin +from sklearn.utils import check_random_state, as_float_array, deprecated +from sklearn.utils.extmath import norm +from sklearn.metrics.pairwise import pairwise_kernels +from sklearn.neighbors import kneighbors_graph +from sklearn.manifold import spectral_embedding +from sklearn.cluster.k_means_ import k_means def discretize(vectors, copy=True, max_svd_restarts=30, n_iter_max=20,