예제 #1
0
def buildMapDict(cube, params, dapver, bintemp=None):
    ''' Build a list of dictionaries of maps

    params - list of string parameter names in form of category_channel

        NOT GENERALIZED
    '''
    # split the bintemp
    if bintemp:
        bintype, temp = bintemp.split('-', 1)
    else:
        bintype, temp = (None, None)

    mapdict = []
    params = params if isinstance(params, list) else [params]

    for param in params:
        param = str(param)
        try:
            parameter, channel = param.split(':')
        except ValueError as e:
            parameter, channel = (param, None)
        webmap, mapmsg = getWebMap(cube,
                                   parameter=parameter,
                                   channel=channel,
                                   bintype=bintype,
                                   template=temp)

        plotparams = datamodel[dapver].get_plot_params(prop=parameter)
        mask = Maskbit('MANGA_DAPPIXMASK')
        baddata_labels = [it for it in plotparams['bitmasks'] if it != 'NOCOV']
        baddata_bits = {
            it.lower(): int(mask.labels_to_bits(it)[0])
            for it in baddata_labels
        }
        plotparams['bits'] = {
            'nocov': int(mask.labels_to_bits('NOCOV')[0]),
            'badData': baddata_bits
        }
        mapdict.append({
            'data': webmap,
            'msg': mapmsg,
            'plotparams': plotparams
        })

    anybad = [m['data'] is None for m in mapdict]
    if any(anybad):
        bad_params = ', '.join([p for i, p in enumerate(params) if anybad[i]])
        raise MarvinError(
            'Could not get map for: {0}.  Please select another.'.format(
                bad_params),
            ignore_git=True)

    return mapdict
예제 #2
0
 def test_labels_to_bits(self, labels, expected):
     mb = Maskbit(name=name, schema=schema, description=description)
     actual = mb.labels_to_bits(labels)
     assert actual == expected