Example #1
0
dt = np.genfromtxt('data/nebulas.tsv', skiprows=51, delimiter='|', usecols=(0, 1, 2, 3, 4),
                   dtype=[('glat', 'float'), ('glong', 'float'), ('ngc', 'int'), ('type', 'S20'), ('messier', 'S20')],
                   converters={3: lambda s: str(s).strip()})

nebula_distance = np.loadtxt('data/nebulas_distance_seds.tsv', skiprows=2, delimiter='|', usecols=(1, 2),
                             dtype=[('ngc', 'int'), ('dist', 'int')])

planetary_nebula_distance = np.loadtxt('data/nebulas_distance_planetary.tsv', skiprows=38, delimiter='|',
                                       usecols=(0, 1),
                                       converters={0: convert_ngc}, dtype=[('ngc', 'int'), ('dist', 'int')])


#================================================================================================


planetary_nebula_distance['dist'] = parsec_to_lightyear(planetary_nebula_distance['dist'])

nebula_distance = np.append(nebula_distance, planetary_nebula_distance)


#================================================================================================


result, indexes = np.unique(dt['ngc'], return_index=True)
dt = dt[indexes]

result, indexes = np.unique(nebula_distance['ngc'], return_index=True)
nebula_distance = nebula_distance[indexes]

dt = np.sort(dt, order=['ngc'])
nebula_distance = np.sort(nebula_distance, order=['ngc'])
Example #2
0
    ngc_string = ngc_string.strip().replace("I", "100")
    return int(ngc_string)

ngc_to_messier = np.loadtxt('data/ngc_to_messier.tsv', skiprows=43, delimiter='|', usecols=(0, 1, 2),
                            dtype = [('ngc', 'int'), ('type', 'S20'), ('messier', 'S20')],
                            converters = {0: convert_ngc2, 1: lambda s: str(s).strip()})


#================================================================================================


fill_with_zeros = np.zeros(data.size)

data = rfn.append_fields(data, ['x', 'y', 'z'], [fill_with_zeros, fill_with_zeros, fill_with_zeros], usemask=False)

data["dist"] = parsec_to_lightyear(data["dist"])

data["glong"] = np.radians(data["glong"])
data["glat"] = np.radians(data["glat"])

data["x"] = data["dist"] * np.cos(data["glat"]) * np.cos(data["glong"])
data["y"] = data["dist"] * np.cos(data["glat"]) * np.sin(data["glong"])
data["z"] = data["dist"] * np.sin(data["glat"])


#================================================================================================


data_all = np.copy(data)