opened
havok2063
username_0
Kate 
Tools - mapplot
Custom mask (running 4th example in ​http://sdss-marvin.readthedocs.io/en/stable/utils/plot-map.html?highlight=mapplot) produces a completely masked plot, does not match expected example when using MPL-6. Works as expected in MPL-5 (although plot does not exactly match the example)
doc example galaxy no longer works in mpl-6
issue
created
bretthandrews
username_1
@katerowlands Can you copy and paste the code that wouldn't work, so I can reproduce this bug?
comment
created
KateRowlands
username_2
from marvin.tools.maps import Maps

maps = Maps(plateifu='8485-1901')
ha = maps['emline_gflux_ha_6564']

masks, __, __ = maps.get_bpt(show_plot=False)

# Create a bitmask for non-star-forming spaxels by taking the
# complement (`~`) of the BPT global star-forming mask (where True == star-forming)
# and mark those spaxels as "DONOTUSE".
mask_non_sf = ~masks['sf']['global'] * ha.pixmask.labels_to_value('DONOTUSE')

# Do a bitwise OR between DAP mask and non-star-forming mask.
mask = ha.mask | mask_non_sf
fig, ax = mapplot.plot(dapmap=ha, mask=mask)  # == ha.plot(mask=mask)
comment
created
KateRowlands
username_2
maps = Maps(plateifu='8485-1901')
ha = maps['emline_gflux_ha_6564']

# get a mask
masks, fig, axes = maps.get_bpt()

# get the spaxel x, y coordinates of our star-forming spaxels
import numpy as np
y, x = np.where(masks['sf']['global'])
print(y)
print(x)

# alternatively, if you want a list of coordinate pairs of [y, x]
coordlist = np.asarray(np.where(masks['sf']['global'])).T.tolist()
print(coordlist[0:2])

# using the star-forming HaEW selection from before
print(sfewha)

# Let's verify this, by looking at the individual spaxel values
# Since numpy.where returns Numpy 0-based indices, we select spaxels using bracket notation [x, y]

# let's check the first one y=13, x=16.
spaxel = maps[x[0], y[0]]
spaxel.emline_gew_ha_6564

# the value property matches the first element in our sfewha array.
# Let's check the 2nd one at y=16, x=16
spaxel = maps[x[1], y[1]]


[]
[]
[]
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-0d555c98ae1d> in <module>()
     13 
     14 # using the star-forming HaEW selection from before
---> 15 print(sfewha)
     16 
     17 # Let's verify this, by looking at the individual spaxel values

NameError: name 'sfewha' is not defined
comment
created
KateRowlands
username_2
The [NII] BPT plot for the second example also looks weird, I'm guessing there is a SNR issue with [NII] or Halpha.
comment
created
bretthandrews
username_1
I'm having trouble reproducing your blank plot. Running the code in the first comment (plus an additional import):
```
from marvin.tools.maps import Maps
import marvin.utils.plot.map as mapplot
maps = Maps(plateifu='8485-1901')
ha = maps['emline_gflux_ha_6564']
masks, __, __ = maps.get_bpt(show_plot=False)
mask_non_sf = ~masks['sf']['global'] * ha.pixmask.labels_to_value('DONOTUSE')
fig, ax = mapplot.plot(dapmap=ha, mask=mask)
```
generates this plot:
![mask_ha](https://user-images.githubusercontent.com/12723826/36565115-81ba5a84-17ed-11e8-9b2e-719455875554.png)

The error in the second comment is caused by not running a few lines from earlier in the web page.
```
import numpy as np
from marvin.tools.maps import Maps
maps = Maps(plateifu='8485-1901')
ha = maps['emline_gflux_ha_6564']
masks, fig, axes = maps.get_bpt()
y, x = np.where(masks['sf']['global'])
print(y)
print(x)
coordlist = np.asarray(np.where(masks['sf']['global'])).T.tolist()
print(coordlist[0:2])

# added these lines
haew = maps.getMap('emline_sew', channel='ha_6564') 
sfewha = haew.value[masks['sf']['global']]

print(sfewha)

spaxel = maps[x[0], y[0]]
spaxel.emline_gew_ha_6564
spaxel = maps[x[1], y[1]]
```
and it produces this plot for me:
![bpt](https://user-images.githubusercontent.com/12723826/36575464-18701f6a-1819-11e8-9d1a-fdcc8f0af928.png)
comment
created
KateRowlands
username_2
Hi Brett,

There is a link missing from the first block of code, should be:

from marvin.tools.maps import Maps
import marvin.utils.plot.map as mapplot

maps = Maps(plateifu='8485-1901')
ha = maps['emline_gflux_ha_6564']
masks, __, __ = maps.get_bpt(show_plot=False)
mask_non_sf = ~masks['sf']['global'] * ha.pixmask.labels_to_value('DONOTUSE')
mask = ha.mask | mask_non_sf
fig, ax = mapplot.plot(dapmap=ha, mask=mask)

Produces:
![screen shot 2018-02-23 at 10 22 55 am](https://user-images.githubusercontent.com/12090407/36601685-b9c73f6e-1883-11e8-9897-a38b7c486dc1.png)

Also, I'm using MPL-6, if I use MPL-5 then I get:
![screen shot 2018-02-23 at 10 25 06 am](https://user-images.githubusercontent.com/12090407/36601735-dec06c5a-1883-11e8-9473-b806a57c48df.png)
comment
created
KateRowlands
username_2
For the 2nd example, apologies I missed the first part of the example If I run:

import numpy as np
from marvin.tools.maps import Maps

maps = Maps(plateifu='8485-1901')

masks, fig, axes = maps.get_bpt()

haew = maps.getMap('emline_sew', channel='ha_6564')
print(haew)

sfewha = haew.value[masks['sf']['global']]
print(sfewha)

y, x = np.where(masks['sf']['global'])
print(y)
print(x)

coordlist = np.asarray(np.where(masks['sf']['global'])).T.tolist()
print(coordlist[0:2])

print(sfewha)

spaxel = maps[x[0], y[0]]
spaxel.emline_gew_ha_6564

spaxel = maps[x[1], y[1]]

I get 
![screen shot 2018-02-23 at 10 34 26 am](https://user-images.githubusercontent.com/12090407/36602110-2a2dbc14-1885-11e8-8f46-169f9da29cb6.png)

[[0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]
 ...
 [0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]] Angstrom
[]
[]
[]
[]
[]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-4-1cf21d32fd14> in <module>()
     21 print(sfewha)
     22 
---> 23 spaxel = maps[x[0], y[0]]
     24 spaxel.emline_gew_ha_6564
     25 

IndexError: index 0 is out of bounds for axis 0 with size 0

 This is because there are no global star-forming spaxels in this galaxy (again using MPL-6).
comment
created
bretthandrews
username_1
The underlying bug causing this issue was a typo in the MPL-6 datamodel. It is fixed by 39c1244f702858cd22aa3316a731866c84c0657a.
comment
closed
bretthandrews
username_1
issue
reopened
bretthandrews
username_1
Kate 
Tools - mapplot
Custom mask (running 4th example in ​http://sdss-marvin.readthedocs.io/en/stable/utils/plot-map.html?highlight=mapplot) produces a completely masked plot, does not match expected example when using MPL-6. Works as expected in MPL-5 (although plot does not exactly match the example)
doc example galaxy in mapplot no longer works in mpl-6
issue
created
bretthandrews
username_1
Why was this issue not raised in testing suite?
comment
closed
bretthandrews
username_1
issue