Hi everyone. I'm a bit stuck on how to unmask a masked numpy array. I'm trying to use both ma.getdata() and .data to do it but neither works.
I'm getting the data from a space telescope called GAIA, which spits out data in "astropy" tables and can be converted to numpy ndarrays or MaskedArrays (it decides on its own). Code below:
import astropy.units as u
from astropy.coordinates.sky_coordinate import SkyCoord
from astropy.units import Quantity
from astroquery.gaia import Gaia
import matplotlib.pyplot as plt
import numpy as np
import numpy.ma as ma
import math
from astroquery.gaia import Gaia
omegaCenPropagated = Gaia.launch_job_async("SELECT EPOCH_PROP(\
ASTROMETRIC_PARAMETERS(ra, dec, parallax, pmra, pmdec, radial_velocity),2015.5,2000) \
FROM gaiadr2.gaia_source \
WHERE CONTAINS(POINT('ICRS',gaiadr2.gaia_source.ra,gaiadr2.gaia_source.dec),CIRCLE('ICRS',201.697,-47.47947222,.3))=1 \
AND abs(pmra_error/pmra)<0.20 \
AND abs(pmdec_error/pmdec)<0.20 \
AND pmra BETWEEN -4.02 AND -3.21 \
AND pmra IS NOT NULL AND abs(pmra)>0 \
AND pmdec IS NOT NULL AND abs(pmdec)>0 \
AND pmdec BETWEEN -6 AND -3.71;")
results = omegaCenPropagated.get_results()
masky = results.as_array()
print(ma.getdata(masky))
>>>[(masked_array(data=[201.35747106846168, -47.28848303227665,
-0.02630335368796253, -3.8819064907919567,
-5.029023407698611, -3.032918049269323e-06],
mask=[False, False, False, False, False, False],
fill_value=1e+20),)
Unmasking a numpy array?
-
- User
- Beiträge: 1
- Registriert: Freitag 17. Juli 2020, 06:52
-
- User
- Beiträge: 491
- Registriert: Mittwoch 13. November 2019, 08:38
Are you sure you tried to access the correct variable and not the module?
Like this:
Like this:
Code: Alles auswählen
>>> import numpy as np
>>> import numpy.ma as ma
>>> x = np.ma.array(np.array([[1, 2], [3, 4]]), mask=[[0, 1], [1, 0]])
>>> x
masked_array(
data=[[1, --],
[--, 4]],
mask=[[False, True],
[ True, False]],
fill_value=999999)
>>> x.data
array([[1, 2],
[3, 4]])