text:
#define _XOPEN_SOURCE 700
#define PCRE2_CODE_UNIT_WIDTH 8

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <pcre2.h>

#include "regex.h"
#include "matrix.h"
#include "commons.h"

// ~ Static function propotypes ==================
static int isCyclicError(const Worksheet *worksheet, const char *visitedCells, CellReference *cellReference);

/**
 * Initializes the worksheet cells of size rows * columns.
 *
 * Returns 0 if an error is encountered.
 */
int initWorksheet(Worksheet *worksheet, int rows, int columns) {
    worksheet->rows = rows;
    worksheet->cols = columns;

    char ***matrix = (char ***) malloc(sizeof(char **) * rows);
    for(int i = 0; i < rows; i++) {
        matrix[i] = (char **) malloc(sizeof(char *) * columns);

        for(int j = 0; j < columns; j++) {
            matrix[i][j] = (char *) calloc(sizeof(char) * CELL_CONTENT_LIMIT, sizeof(char));
        }
    }

    worksheet->cells = matrix;
    return 1;
}

int closeWorksheet(Worksheet *w)
{
    for(int i = 0; i < w->rows; i++)
    {
        for(int j = 0; j < w->cols; j++)
        {
            free(w->cells[i][j]);
        }
        free(w->cells[i]);
    }
    free(w->cells);
    free(w);
    return 1;
}

/**
 * Sets s to the worksheet cell at row, column.
 *
 * Returns 0 if strlen(s) > CELL_CONTENT_LIMIT
 */
int setValue(Worksheet *worksheet, int row, int column, char* s) {
    if (strlen(s) <= CELL_CONTENT_LIMIT) {
        strncpy(worksheet->cells[row][column], s, strlen(s));
        return 1;
    } else {
        return 0;
    }
}

/**
 * Returns the value at row, col
 */
char* getValue(const Worksheet *worksheet, int row, int column) {
    return worksheet->cells[row][column];
}

int getValue2(const Worksheet *w, char **buffer, int row, int column)
{
    if (w == NULL) return 0;
    if (w->cells[row][column] == NULL) return 0;

    *buffer = malloc(sizeof(char) * strlen(w->cells[row][column]) + 1);
    strcpy(*buffer, w->cells[row][column]);

    return 1;
}

/**
 * Converts the given location (row, column) to a spreadsheet cell reference i.e. A1
 */
CellReference *convertToCellReference(const MatrixLocation *location)
{
    CellReference *ref = malloc(sizeof(CellReference));

    char *colRef = malloc(sizeof(char) * getNumberOfDigits(location->col) + 1);
    sprintf(colRef, "%d", location->col + 1);

    // row ref + col ref + null terminator
    ref->cellReference = malloc(sizeof(char) * (1 + strlen(colRef) + 1) + 1);
    sprintf(ref->cellReference, "%c%s", (char)(location->row + ROW_TO_ASCII_OFFSET), colRef);
    free(colRef);

    return ref;
}

/**
 * Returns a pointer to a MatrixLocation structure
 */
MatrixLocation *convertToMatrixLocation(const CellReference *ref)
{
    MatrixLocation *loc = malloc(sizeof(MatrixLocation));
    loc->row = ((int) toupper(ref->cellReference[0])) - ROW_TO_ASCII_OFFSET;

    char *col = calloc(sizeof(char) + strlen(ref->cellReference), sizeof(char));
    col = strncpy(col, ref->cellReference + 1, strlen(ref->cellReference) - 1);
    loc->col = atoi(col) - 1;
    free(col);
    return loc;
}

/**
 * Checks if a given formula at row, col refers to some cells which themselves
 * refer back to row,col
 *
 * Returns 0 if an error is encountered.
 */
int isCyclicRefError(const Worksheet *worksheet, int row, int col)
{
    MatrixLocation m = { row, col };

    CellReference *cellRef = convertToCellReference(&m);
    int result = isCyclicError(worksheet, "", cellRef);

    free(cellRef->cellReference);
    free(cellRef);
    return result;
}

/**
 * An internal function for checking cyclic reference dependency error.
 *
 * ==========
 * Returns 1 if cyclic dependency is found, 0 if otherwise
 */
static int isCyclicError(const Worksheet *worksheet, const char *visitedCells, CellReference *cellRef)
{
    pcre2_match_data *match_data = NULL;
    char *saveptr = NULL;
    int rc = 0;

    MatrixLocation *m = convertToMatrixLocation(cellRef);

    char *cellValue = NULL;
    getValue2(worksheet, &cellValue, m->row, m->col);
    free(m);

    if (cellValue == NULL)
    {
        return 0;
    }

    // do work on working copy
    char *token = NULL;
    token = strtok_r(cellValue, " ", &saveptr);
    pcre2_code *re = getCellReferencePattern();
    while(token != NULL)
    {
        match_data = pcre2_match_data_create(20, NULL);
        int subjectLength = strlen(token);
        rc = pcre2_match(re, (PCRE2_SPTR) token, subjectLength, 0, 0, match_data, NULL);

        if (rc > 0)
        {
            // search if current cellref is in the visited cells
            pcre2_code *searchVal = compilePattern(token);
            int isCyclicDependency = pcre2_match(searchVal, (PCRE2_SPTR) visitedCells, strlen(visitedCells), 0, 0, match_data, NULL);
            if (isCyclicDependency > 0)
            {
                free(cellValue);
                free(match_data);
                free(searchVal);
                free(re);
                return 1;
            }

            free(searchVal);

            //length of existing visitedCells + space character + length of cellRef to be appended + null terminator
            char *newVisitedCells = malloc(sizeof(char) * (strlen(visitedCells) + 1 + strlen(cellRef->cellReference)) + 1);
            strcpy(newVisitedCells, visitedCells);
            strcat(newVisitedCells, " ");
            strcat(newVisitedCells, cellRef->cellReference);

            CellReference *tokenCellRef = malloc(sizeof(CellReference));
            tokenCellRef->cellReference = token;

            if(isCyclicError(worksheet, (const char *) newVisitedCells, tokenCellRef))
            {
                free(cellValue);
                free(newVisitedCells);
                free(match_data);
                free(re);
                return 1;
            }

            free(newVisitedCells);
            free(tokenCellRef);
        }
        token = strtok_r(NULL, " ", &saveptr);
        free(match_data);
    }

    free(cellValue);
    free(re);
    return 0;
}


text:
package com.github.mikephil.charting.renderer;

import com.github.mikephil.charting.interfaces.dataprovider.BarLineScatterCandleBubbleDataProvider;
import com.github.mikephil.charting.utils.ViewPortHandler;

/**
 * Abstract baseclass of all Renderers.
 *
 * @author Philipp Jahoda
 */
public abstract class Renderer {

    /**
     * the component that handles the drawing area of the chart and it's offsets
     */
    protected ViewPortHandler mViewPortHandler;

    /** the minimum value on the x-axis that should be plotted */
    protected int mMinX = 0;

    /** the maximum value on the x-axis that should be plotted */
    protected int mMaxX = 0;

    public Renderer(ViewPortHandler viewPortHandler) {
        this.mViewPortHandler = viewPortHandler;
    }

    /**
     * Returns true if the specified value fits in between the provided min
     * and max bounds, false if not.
     *
     * @param val
     * @param min
     * @param max
     * @return
     */
    protected boolean fitsBounds(float val, float min, float max) {

        if (val < min || val > max)
            return false;
        else
            return true;
    }

    /**
     * Calculates the minimum and maximum x-value the chart can currently
     * display (with the given zoom level). -> mMinX, mMaxX
     *
     * @param dataProvider
     * @param xAxisModulus
     */
    public void calcXBounds(BarLineScatterCandleBubbleDataProvider dataProvider, int xAxisModulus) {

        int low = dataProvider.getLowestVisibleXIndex();
        int high = dataProvider.getHighestVisibleXIndex();

        int subLow = (low % xAxisModulus == 0) ? xAxisModulus : 0;

        mMinX = Math.max((low / xAxisModulus) * (xAxisModulus) - subLow, 0);
        mMaxX = Math.min((high / xAxisModulus) * (xAxisModulus) + xAxisModulus, (int) dataProvider.getXChartMax());
    }
}

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using System.Security.Permissions;

namespace System.IO.IsolatedStorage {

    public class IsolatedStorageGroup {
        public string m_Group;
        public Int64 m_Quota;
        public Int64 m_UsedSize;
        private string m_GroupPath;
        private string m_ObfuscatedId;

        #if FEATURE_CORECLR
        [System.Security.SecurityCritical] // auto-generated
        #endif
        internal IsolatedStorageGroup(string group, long quota, long used, string groupPath) {
            m_Group = group;
            m_Quota = quota;
            m_UsedSize = used;
            m_ObfuscatedId = DirectoryInfo.UnsafeCreateDirectoryInfo(groupPath).Name;
            m_GroupPath = groupPath;
        }

        public string Group {
            get {
                return m_Group;
            }
        }

        public Int64 Quota {
            get {
                return m_Quota;
            }
        }

        public Int64 UsedSize {
            get {
                return m_UsedSize;
            }
        }

        public static Boolean Enabled {
            #if FEATURE_CORECLR
            [System.Security.SecurityCritical] // auto-generated
            #endif
            get {
                try {
                    return !File.UnsafeExists(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.c_DisabledFileName));
                } catch (IsolatedStorageException) {
                    // IsolatedStorageRoot will throw this if the host doesn't hand back a root, which can happen when running in "Private Browsing Mode".
                    return false;
                }
            }

            #if FEATURE_CORECLR
            [System.Security.SecurityCritical] // auto-generated
            #endif
            set {
                if (!value) {
                    IsolatedStorageFile.TouchFile(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.c_DisabledFileName));
                } else {
                    try {
                        File.UnsafeDelete(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.c_DisabledFileName));
                    } catch (IOException) {
                        // If we couldn't delete the file there's nothing much we can do.
                    }
                }
            }
        }

        #if FEATURE_CORECLR
        [System.Security.SecurityCritical] // auto-generated
        #endif
        public void Remove() {
#if !FEATURE_LEGACYNETCF
            bool removedAll = true;
            FileLock groupLock = FileLock.GetFileLock(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_LockPathPrefix), IsolatedStorageFile.s_GroupPathPrefix + "-" + m_ObfuscatedId);

            try {
                groupLock.Lock();

                foreach (string storeDir in Directory.UnsafeGetDirectories(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_StorePathPrefix), "*", SearchOption.TopDirectoryOnly)) {
                    string groupFile = Path.Combine(storeDir, IsolatedStorageFile.s_GroupFileName);

                    if (m_ObfuscatedId.Equals(File.UnsafeReadAllText(groupFile))) {
                        IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreFromGroupAndStorePath(Group, storeDir);
                        removedAll = removedAll & f.TryRemove();
                    }
                }

                IsolatedStorageFile.TouchFile(Path.Combine(m_GroupPath, IsolatedStorageFile.s_CleanupFileName));

                if (removedAll) {
                    IsolatedStorageAccountingInfo.RemoveAccountingInfo(m_GroupPath);
                    File.UnsafeDelete(Path.Combine(m_GroupPath, IsolatedStorageFile.s_IdFileName));
                    File.UnsafeDelete(Path.Combine(m_GroupPath, IsolatedStorageFile.s_CleanupFileName));
                    Directory.UnsafeDelete(m_GroupPath, false);
                }
            } catch (IOException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } catch (UnauthorizedAccessException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } finally {
                groupLock.Unlock();
            }
#else // !FEATURE_LEGACYNETCF
            try {
                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
                    isf.Remove();
                }
            } catch (IOException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } catch (UnauthorizedAccessException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            }
#endif // !FEATURE_LEGACYNETCF
        }

        #if FEATURE_CORECLR
        [System.Security.SecurityCritical] // auto-generated
        #endif
        public static IEnumerable<IsolatedStorageGroup> GetGroups() {

            List<IsolatedStorageGroup> groups = new List<IsolatedStorageGroup>();
#if !FEATURE_LEGACYNETCF
            try {
                foreach (string groupDir in Directory.UnsafeGetDirectories(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_GroupPathPrefix), "*", SearchOption.TopDirectoryOnly)) {
                    string idFile = Path.Combine(groupDir, IsolatedStorageFile.s_IdFileName);
                    string id;

                    FileLock groupLock = FileLock.GetFileLock(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_LockPathPrefix), IsolatedStorageFile.s_GroupPathPrefix + "-" + DirectoryInfo.UnsafeCreateDirectoryInfo(groupDir).Name);

                    try {
                        groupLock.Lock();

                        if(!File.UnsafeExists(Path.Combine(groupDir, IsolatedStorageFile.s_CleanupFileName))) {
                            id = File.UnsafeReadAllText(idFile);

                            if (IsolatedStorageAccountingInfo.IsAccountingInfoValid(groupDir)) {
                                using (IsolatedStorageAccountingInfo accountingInfo = new IsolatedStorageAccountingInfo(groupDir)) {
                                    groups.Add(new IsolatedStorageGroup(id, accountingInfo.Quota, accountingInfo.UsedSize, groupDir));
                                }
                            } else {
                                // In this case we've tried to deseriaize a group that doesn't have valid data.  We'll try to remove it.
                                try {
                                    new IsolatedStorageGroup(id, 0, 0, groupDir).Remove();
                                } catch (Exception) {
                                    // We couldn't remove the group for some reason.  Ignore it and move on.
                                }
                            }
                        }
                    } catch (IOException) {
                        // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
                    } catch (UnauthorizedAccessException) {
                        // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
                    } finally {
                        groupLock.Unlock();
                    }
                }
            } catch (IOException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } catch (UnauthorizedAccessException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            }
#else
            try {
                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
                    groups.Add(new IsolatedStorageGroup(isf.GroupName, Int64.MaxValue, 0, IsolatedStorageFile.IsolatedStorageRoot));
                }
            } catch (IOException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } catch (UnauthorizedAccessException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } catch (IsolatedStorageException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            }
#endif

            return groups;
        }

        #if FEATURE_CORECLR
        [System.Security.SecurityCritical] // auto-generated
        #endif
        public static void RemoveAll() {
            foreach (IsolatedStorageGroup g in GetGroups()) {
                g.Remove();
            }
        }
    }
}


text:
<?php
use Oasis\Mlib\Utils\Exceptions\InvalidDataTypeException;
use Oasis\Mlib\Utils\Validators\FloatValidator;

/**
 * Created by PhpStorm.
 * User: minhao
 * Date: 2016-09-02
 * Time: 15:59
 */
class FloatValidatorTest extends PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider getInvalidInputInStrictMode
     *
     * @param $target
     */
    public function testStrictModeInvalidInput($target)
    {
        $validator = new FloatValidator(true);

        $this->expectException(InvalidDataTypeException::class);
        $this->assertTrue(is_float($validator->validate($target)));
    }

    /**
     * @dataProvider getValidInputInStrictMode
     *
     * @param $target
     */
    public function testStrictModeValid($target)
    {
        $validator = new FloatValidator(true);

        $this->assertTrue(is_float($validator->validate($target)));
    }

    /**
     * @dataProvider getInvalidInputInNonStrictMode
     *
     * @param $target
     */
    public function testNonStrictModeInvalidInput($target)
    {
        $validator = new FloatValidator(false);

        $this->expectException(InvalidDataTypeException::class);
        $this->assertTrue(is_float($validator->validate($target)));
    }

    /**
     * @dataProvider getValidInputInNonStrictMode
     *
     * @param $target
     */
    public function testNonStrictModeValid($target)
    {
        $validator = new FloatValidator(false);

        $this->assertTrue(is_float($validator->validate($target)));
    }

    public function getInvalidInputInStrictMode()
    {
        return [
            [''],
            ['abc'],
            ['123'],
            ['123.5'],
            [10],
            [0],
            [null],
            [true],
            [false],
            [new stdClass()],
            [[]],
            [[123]],
        ];
    }

    public function getInvalidInputInNonStrictMode()
    {
        return [
            [''],
            ['abc'],
            [PHP_INT_MAX], // precision too high
            [123456789012345], // precision too high
            [null],
            [true],
            [false],
            [new stdClass()],
            [[]],
            [[123]],
        ];
    }

    public function getValidInputInNonStrictMode()
    {
        return [
            [10],
            [0],
            [5.0],
            [0.0],
            [12345678901234], // precision ok
            ['10'],
            ['0'],
            ['10.3'],
            ['0.0'],
        ];
    }

    public function getValidInputInStrictMode()
    {
        return [
            [1.0],
            [0.0],
        ];
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Nuovo Giorn. Bot. Ital. 7(1): 43 (1875)

#### Original name
Glyphis labyrinthica var. prorecta Kremp.

### Remarks
null


text:
'use strict';

/**
* Test if a value is a binary string.
*
* @module @stdlib/assert/is-binary-string
*
* @example
* var isBinaryString = require( '@stdlib/assert/is-binary-string' );
*
* var bool = isBinaryString( '1000101' );
* // returns true
*
* bool = isBinaryString( 'beep' );
* // returns false
*
* bool = isBinaryString( '' );
* // returns false
*/

// MODULES //

var main = require( './main.js' );

// EXPORTS //

module.exports = main;


text:
_author__ = 'pdh21'

import numpyro
import numpyro.distributions as dist
from numpyro.infer.reparam import TransformReparam
import jax.numpy as jnp
import numpy as np
from xidplus.numpyro_fit.misc import sp_matmul

def spire_model_CIGALE(priors, sed_prior,params):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    #get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    #background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # redshift-sfr relation parameters
    m = numpyro.sample('m', dist.Normal(params['m_mu'], params['m_sig']))
    c = numpyro.sample('c', dist.Normal(params['c_mu'], params['c_sig']))

    #sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    #sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        #use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(0.01, sed_prior.params_mu[:, 1], sed_prior.params_sig[:, 1]))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        # use handlers.reparam as sampling from standard normal and transforming by redshift relation
        #with numpyro.handlers.reparam(config={"params": TransformReparam()}):
            #sfr = numpyro.sample('sfr', dist.TransformedDistribution(dist.Normal(0.0, 1.0),
                                                                     #dist.transforms.AffineTransform(redshift * m + c,
                                                                                # jnp.full(
                                                                                # priors[0].nsrc,
                                                                                # sfr_sig))))
        sfr = numpyro.sample('sfr', dist.Normal(redshift * m + c,jnp.full(priors[0].nsrc,sfr_sig)))

    #stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_psw = sp_matmul(pointing_matrices[0], src_f[:, 0][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_pmw = sp_matmul(pointing_matrices[1], src_f[:, 1][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_plw = sp_matmul(pointing_matrices[2], src_f[:, 2][:, None], priors[2].snpix).reshape(-1) + bkg[2]

    # for each band, condition on data
    with numpyro.plate('psw_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_psw", dist.Normal(db_hat_psw, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('pmw_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_pmw", dist.Normal(db_hat_pmw, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('plw_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_plw", dist.Normal(db_hat_plw, priors[2].snim),
                       obs=priors[2].sim)

def spire_model_CIGALE(priors, sed_prior, params):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # redshift-sfr relation parameters
    m = numpyro.sample('m', dist.Normal(params['m_mu'], params['m_sig']))
    c = numpyro.sample('c', dist.Normal(params['c_mu'], params['c_sig']))

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(0.01, sed_prior.params_mu[:, 1], sed_prior.params_sig[:, 1]))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        # use handlers.reparam as sampling from standard normal and transforming by redshift relation
        # with numpyro.handlers.reparam(config={"params": TransformReparam()}):
        # sfr = numpyro.sample('sfr', dist.TransformedDistribution(dist.Normal(0.0, 1.0),
        # dist.transforms.AffineTransform(redshift * m + c,
        # jnp.full(
        # priors[0].nsrc,
        # sfr_sig))))
        sfr = numpyro.sample('sfr', dist.Normal(redshift * m + c, jnp.full(priors[0].nsrc, sfr_sig)))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_psw = sp_matmul(pointing_matrices[0], src_f[:, 0][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_pmw = sp_matmul(pointing_matrices[1], src_f[:, 1][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_plw = sp_matmul(pointing_matrices[2], src_f[:, 2][:, None], priors[2].snpix).reshape(-1) + bkg[2]

    # for each band, condition on data
    with numpyro.plate('psw_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_psw", dist.Normal(db_hat_psw, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('pmw_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_pmw", dist.Normal(db_hat_pmw, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('plw_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_plw", dist.Normal(db_hat_plw, priors[2].snim),
                       obs=priors[2].sim)

def spire_model_CIGALE_schect(priors, sed_prior, params):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # redshift-sfr relation parameters
    z_star = numpyro.sample('m', dist.TruncatedNormal(0.01,params['z_star_mu'], params['z_star_sig']))
    sfr_star = numpyro.sample('c', dist.TruncatedNormal(0.01,params['sfr_star_mu'], params['sfr_star_sig']))
    alpha= params['alpha']

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(0.01, sed_prior.params_mu[:, 1], sed_prior.params_sig[:, 1]))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        # use handlers.reparam as sampling from standard normal and transforming by redshift relation
        # with numpyro.handlers.reparam(config={"params": TransformReparam()}):
        # sfr = numpyro.sample('sfr', dist.TransformedDistribution(dist.Normal(0.0, 1.0),
        # dist.transforms.AffineTransform(redshift * m + c,
        # jnp.full(
        # priors[0].nsrc,
        # sfr_sig))))
        sfr = numpyro.sample('sfr', dist.Normal((sfr_star*jnp.exp(-1.0*redshift/z_star)*(redshift/z_star)**alpha)-2.0, jnp.full(priors[0].nsrc, sfr_sig)))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_psw = sp_matmul(pointing_matrices[0], src_f[:, 0][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_pmw = sp_matmul(pointing_matrices[1], src_f[:, 1][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_plw = sp_matmul(pointing_matrices[2], src_f[:, 2][:, None], priors[2].snpix).reshape(-1) + bkg[2]

    # for each band, condition on data
    with numpyro.plate('psw_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_psw", dist.Normal(db_hat_psw, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('pmw_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_pmw", dist.Normal(db_hat_pmw, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('plw_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_plw", dist.Normal(db_hat_plw, priors[2].snim),
                       obs=priors[2].sim)

def spire_model_CIGALE_kasia_schect(priors, sed_prior):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # redshift-sfr relation parameters
    z_star = numpyro.sample('z_star', dist.TruncatedNormal(loc=sed_prior.hier_params['z_star_mu'], scale=sed_prior.hier_params['z_star_sig'],low=0.01,))
    sfr_star = numpyro.sample('sfr_star', dist.TruncatedNormal(loc=sed_prior.hier_params['sfr_star_mu'], scale=sed_prior.hier_params['sfr_star_sig'],low=0.01,))
    alpha= sed_prior.hier_params['alpha']

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(sed_prior.hier_params['sfr_disp']))

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=sed_prior.phys_prior_table['z_mu'].data,scale= sed_prior.phys_prior_table['z_sig'],low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(sed_prior.phys_prior_table['fracAGN_alpha'], sed_prior.phys_prior_table['fracAGN_beta']))

        sfr = numpyro.sample('sfr', dist.Normal((sfr_star*jnp.exp(-1.0*redshift/z_star)*(redshift/z_star)**alpha)-2.0, jnp.full(priors[0].nsrc, sfr_sig)))

        atten=numpyro.sample('atten',dist.TruncatedNormal(loc=sed_prior.phys_prior_table['atten_mu'],scale=sed_prior.phys_prior_table['atten_sig'],low=0.01))

        dust_alpha=numpyro.sample('dust_alpha',dist.TruncatedNormal(loc=sed_prior.phys_prior_table['dust_alpha_mu'], scale=sed_prior.phys_prior_table['dust_alpha_sig'],low=0.01))

        tau_main=numpyro.sample('tau_main',dist.Normal(sed_prior.phys_prior_table['tau_main_mu'], sed_prior.phys_prior_table['tau_main_sig']))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_psw = sp_matmul(pointing_matrices[0], src_f[:, -3][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_pmw = sp_matmul(pointing_matrices[1], src_f[:, -2][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_plw = sp_matmul(pointing_matrices[2], src_f[:, -1][:, None], priors[2].snpix).reshape(-1) + bkg[2]

    # for each band, condition on data
    with numpyro.plate('psw_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_psw", dist.Normal(db_hat_psw, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('pmw_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_pmw", dist.Normal(db_hat_pmw, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('plw_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_plw", dist.Normal(db_hat_plw, priors[2].snim),
                       obs=priors[2].sim)

def spire_model_CIGALE_kasia_schect_bands(priors, sed_prior, params,flux,flux_error):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # redshift-sfr relation parameters
    z_star = numpyro.sample('m', dist.TruncatedNormal(loc=params['z_star_mu'], scale=params['z_star_sig'], low=0.01))
    sfr_star = numpyro.sample('c',
                              dist.TruncatedNormal(loc=params['sfr_star_mu'], scale=params['sfr_star_sig'], low=0.01))
    alpha = params['alpha']

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    plate_sources = numpyro.plate('nsrc', priors[0].nsrc)

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with plate_sources:
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=sed_prior.params_mu[:, 1], scale=sed_prior.params_sig[:, 1],
                                                       low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        sfr = numpyro.sample('sfr', dist.Normal(
                (sfr_star * jnp.exp(-1.0 * redshift / z_star) * (redshift / z_star) ** alpha) - 2.0,
                jnp.full(priors[0].nsrc, sfr_sig)))

        atten = numpyro.sample('atten',
                               dist.TruncatedNormal(loc=sed_prior.params_mu[:, 2], scale=sed_prior.params_sig[:, 2],
                                                    low=0.0))

        dust_alpha = numpyro.sample('dust_alpha', dist.TruncatedNormal(loc=sed_prior.params_mu[:, 3],
                                                                       scale=sed_prior.params_sig[:, 3], low=0.0))

        tau_main = numpyro.sample('tau_main', dist.Normal(sed_prior.params_mu[:, 4], sed_prior.params_sig[:, 4]))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    with plate_sources:
        # for each band, condition on data
        numpyro.sample("obs_250", dist.Normal(src_f[:, -3], flux_error[0,:]),
                       obs=flux[0,:])
        numpyro.sample("obs_350", dist.Normal(src_f[:, -2], flux_error[1, :]),
                        obs=flux[1, :])
        numpyro.sample("obs_500", dist.Normal(src_f[:, -1], flux_error[2, :]),
                        obs=flux[2, :])

def spire_model_CIGALE_kasia_schect_irac(priors, sed_prior,irac_cut,irac_flux,irac_sigma):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    plate_sources = numpyro.plate('nsrc', priors[0].nsrc)
    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # redshift-sfr relation parameters
    z_star = numpyro.sample('z_star', dist.TruncatedNormal(loc=sed_prior.hier_params['z_star_mu'],
                                                           scale=sed_prior.hier_params['z_star_sig'], low=0.01, ))
    sfr_star = numpyro.sample('sfr_star', dist.TruncatedNormal(loc=sed_prior.hier_params['sfr_star_mu'],
                                                               scale=sed_prior.hier_params['sfr_star_sig'], low=0.01, ))
    alpha = sed_prior.hier_params['alpha']

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(sed_prior.hier_params['sfr_disp']))

    #aan additional parameter to add dispersion to the irac band in SED fitting
    irac_global_sigma=numpyro.sample('irac_global_sigma',dist.HalfNormal(0.1))

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with plate_sources:
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=sed_prior.phys_prior_table['z_mu'].data,
                                                       scale=sed_prior.phys_prior_table['z_sig'], low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(sed_prior.phys_prior_table['fracAGN_alpha'],
                                              sed_prior.phys_prior_table['fracAGN_beta']))

        sfr = numpyro.sample('sfr', dist.Normal(
            (sfr_star * jnp.exp(-1.0 * redshift / z_star) * (redshift / z_star) ** alpha) - 2.0,
            jnp.full(priors[0].nsrc, sfr_sig)))

        atten = numpyro.sample('atten', dist.TruncatedNormal(loc=sed_prior.phys_prior_table['atten_mu'],
                                                             scale=sed_prior.phys_prior_table['atten_sig'], low=0.01))

        dust_alpha = numpyro.sample('dust_alpha', dist.TruncatedNormal(loc=sed_prior.phys_prior_table['dust_alpha_mu'],
                                                                       scale=sed_prior.phys_prior_table[
                                                                           'dust_alpha_sig'], low=0.01))

        tau_main = numpyro.sample('tau_main', dist.Normal(sed_prior.phys_prior_table['tau_main_mu'],
                                                          sed_prior.phys_prior_table['tau_main_sig']))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack(
            (sfr[None, :], agn[None, :], redshift[None, :], atten[None, :], dust_alpha[None, :], tau_main[None, :])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_psw = sp_matmul(pointing_matrices[0], src_f[:, -3][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_pmw = sp_matmul(pointing_matrices[1], src_f[:, -2][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_plw = sp_matmul(pointing_matrices[2], src_f[:, -1][:, None], priors[2].snpix).reshape(-1) + bkg[2]

    with plate_sources:
        numpyro.sample('obs_irac',dist.TruncatedNormal(low=irac_cut,loc=src_f[:,-4],scale=irac_sigma+irac_global_sigma),obs=irac_flux)
    # for each band, condition on data
    with numpyro.plate('psw_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_psw", dist.Normal(db_hat_psw, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('pmw_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_pmw", dist.Normal(db_hat_pmw, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('plw_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_plw", dist.Normal(db_hat_plw, priors[2].snim),
                       obs=priors[2].sim)

def SFRD(z,z1,z2,a1,a2,sig1,sig2):
    return a1*jnp.exp(-0.5*jnp.power((z-z1)/sig1,2))+a2*jnp.exp(-0.5*jnp.power((z-z2)/sig2,2))

def spire_model_CIGALE_kasia_SFRD(priors, sed_prior, params):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # redshift-sfr relation parameters
    z_1 = numpyro.sample('z1', dist.TruncatedNormal(0.01,params['z_1_mu'], params['z_1_sig']))
    z_2 = numpyro.sample('z2', dist.TruncatedNormal(0.01,params['z_2_mu'], params['z_2_sig']))
    sig_1 = numpyro.sample('sig1',dist.TruncatedNormal(0.01,params['sig_1_mu'], params['sig_1_sig']))
    sig_2 = numpyro.sample('sig2',dist.TruncatedNormal(0.01,params['sig_2_mu'], params['sig_2_sig']))
    a1 = numpyro.sample('a1', dist.TruncatedNormal(0.01,params['a_1_mu'], params['a_1_sig']))
    a2 = numpyro.sample('a2', dist.TruncatedNormal(0.01,params['a_2_mu'], params['a_2_sig']))

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(0.01, sed_prior.params_mu[:, 1], sed_prior.params_sig[:, 1]))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        sfr = numpyro.sample('sfr', dist.Normal(jnp.log10(SFRD(redshift,z_1,z_2,a1,a2,sig_1,sig_2)), jnp.full(priors[0].nsrc, sfr_sig)))

        atten=numpyro.sample('atten',dist.TruncatedNormal(0.0, sed_prior.params_mu[:, 2], sed_prior.params_sig[:, 2]))

        dust_alpha=numpyro.sample('dust_alpha',dist.TruncatedNormal(0.0, sed_prior.params_mu[:, 3], sed_prior.params_sig[:, 3]))

        tau_main=numpyro.sample('tau_main',dist.Normal(sed_prior.params_mu[:, 4], sed_prior.params_sig[:, 4]))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_psw = sp_matmul(pointing_matrices[0], src_f[:, -3][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_pmw = sp_matmul(pointing_matrices[1], src_f[:, -2][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_plw = sp_matmul(pointing_matrices[2], src_f[:, -1][:, None], priors[2].snpix).reshape(-1) + bkg[2]

    # for each band, condition on data
    with numpyro.plate('psw_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_psw", dist.Normal(db_hat_psw, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('pmw_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_pmw", dist.Normal(db_hat_pmw, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('plw_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_plw", dist.Normal(db_hat_plw, priors[2].snim),
                       obs=priors[2].sim)

def spire_model_CIGALE_mainseq(priors, sed_prior,z_cut,z_flux,z_sigma,i_cut,i_flux,i_sigma):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    plate_sources = numpyro.plate('nsrc', priors[0].nsrc)
    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # main sequence relation parameters
    alpha = numpyro.sample('alpha', dist.Normal(sed_prior.hier_params['alpha_mu'], sed_prior.hier_params['alpha_sig']))
    beta = numpyro.sample('beta', dist.Normal(sed_prior.hier_params['beta_mu'], sed_prior.hier_params['beta_sig']))

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(sed_prior.hier_params['sfr_disp']))

    #aan additional parameter to add dispersion to the irac band in SED fitting
    z_global_sigma=numpyro.sample('z_global_sigma',dist.HalfNormal(0.1))
    i_global_sigma=numpyro.sample('i_global_sigma',dist.HalfNormal(0.1))

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with plate_sources:
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=sed_prior.phys_prior_table['z_mu'].data,
                                                       scale=sed_prior.phys_prior_table['z_sig'], low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(sed_prior.phys_prior_table['fracAGN_alpha'],
                                              sed_prior.phys_prior_table['fracAGN_beta']))

        m_star=numpyro.sample('mstar',dist.Normal(sed_prior.phys_prior_table['stellar_mass_mu'],sed_prior.phys_prior_table['stellar_mas_sig']))

        sfr = numpyro.sample('sfr', dist.Normal(alpha*m_star+beta, jnp.full(priors[0].nsrc, sfr_sig)))

        atten = numpyro.sample('atten', dist.TruncatedNormal(loc=sed_prior.phys_prior_table['atten_mu'],
                                                             scale=sed_prior.phys_prior_table['atten_sig'], low=0.01))

        dust_alpha = numpyro.sample('dust_alpha', dist.TruncatedNormal(loc=sed_prior.phys_prior_table['dust_alpha_mu'],
                                                                       scale=sed_prior.phys_prior_table[
                                                                           'dust_alpha_sig'], low=0.01))

        tau_main = numpyro.sample('tau_main', dist.Normal(sed_prior.phys_prior_table['tau_main_mu'],
                                                          sed_prior.phys_prior_table['tau_main_sig']))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None, :], dust_alpha[None, :],
                         tau_main[None, :], m_star[None, :])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_psw = sp_matmul(pointing_matrices[0], src_f[:, -3][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_pmw = sp_matmul(pointing_matrices[1], src_f[:, -2][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_plw = sp_matmul(pointing_matrices[2], src_f[:, -1][:, None], priors[2].snpix).reshape(-1) + bkg[2]

    with plate_sources:
        numpyro.sample('obs_z',dist.TruncatedNormal(low=z_cut,loc=src_f[:,-4],scale=z_sigma+z_global_sigma),obs=z_flux)
        numpyro.sample('obs_i',dist.TruncatedNormal(low=i_cut,loc=src_f[:,2],scale=i_sigma+i_global_sigma),obs=i_flux)

    # for each band, condition on data
    with numpyro.plate('psw_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_psw", dist.Normal(db_hat_psw, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('pmw_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_pmw", dist.Normal(db_hat_pmw, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('plw_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_plw", dist.Normal(db_hat_plw, priors[2].snim),
                       obs=priors[2].sim)

def GEP_CIGALE_schect(priors, sed_prior, params):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

        # redshift-sfr relation parameters
    z_star = numpyro.sample('m', dist.TruncatedNormal(loc=params['z_star_mu'], scale=params['z_star_sig'], low=0.01))
    sfr_star = numpyro.sample('c',
                              dist.TruncatedNormal(loc=params['sfr_star_mu'], scale=params['sfr_star_sig'], low=0.01))
    alpha = params['alpha']

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=sed_prior.params_mu[:, 1], scale=sed_prior.params_sig[:, 1],
                                                       low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        sfr = numpyro.sample('sfr', dist.Normal(
            (sfr_star * jnp.exp(-1.0 * redshift / z_star) * (redshift / z_star) ** alpha) - 2.0,
            jnp.full(priors[0].nsrc, sfr_sig)))

        atten = numpyro.sample('atten',
                               dist.TruncatedNormal(loc=sed_prior.params_mu[:, 2], scale=sed_prior.params_sig[:, 2],
                                                    low=0.0))

        dust_alpha = numpyro.sample('dust_alpha', dist.TruncatedNormal(loc=sed_prior.params_mu[:, 3],
                                                                       scale=sed_prior.params_sig[:, 3], low=0.0))

        tau_main=numpyro.sample('tau_main',dist.Normal(sed_prior.params_mu[:, 4], sed_prior.params_sig[:, 4]))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_19 = sp_matmul(pointing_matrices[0], src_f[:, 18][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_20 = sp_matmul(pointing_matrices[1], src_f[:, 19][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_21 = sp_matmul(pointing_matrices[2], src_f[:, 20][:, None], priors[2].snpix).reshape(-1) + bkg[2]
    db_hat_22 = sp_matmul(pointing_matrices[3], src_f[:, 21][:, None], priors[3].snpix).reshape(-1) + bkg[3]
    db_hat_23 = sp_matmul(pointing_matrices[4], src_f[:, 22][:, None], priors[4].snpix).reshape(-1) + bkg[4]

    # for each band, condition on data
    with numpyro.plate('gep19_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_gep19", dist.Normal(db_hat_19, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('gep20_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_gep20", dist.Normal(db_hat_20, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('gep21_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep21", dist.Normal(db_hat_21, priors[2].snim),
                       obs=priors[2].sim)
    with numpyro.plate('gep22_pixels', priors[3].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep22", dist.Normal(db_hat_22, priors[3].snim),
                       obs=priors[3].sim)
    with numpyro.plate('gep23_pixels', priors[4].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep23", dist.Normal(db_hat_23, priors[4].snim),
                       obs=priors[4].sim)

def GEP_CIGALE_schect_19(priors, sed_prior, params):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # redshift-sfr relation parameters
    z_star = numpyro.sample('m', dist.TruncatedNormal(loc=params['z_star_mu'], scale=params['z_star_sig'],low=0.01))
    sfr_star = numpyro.sample('c', dist.TruncatedNormal(loc=params['sfr_star_mu'],scale=params['sfr_star_sig'],low=0.01))
    alpha= params['alpha']

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc= sed_prior.params_mu[:, 1],scale=sed_prior.params_sig[:, 1],low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        sfr = numpyro.sample('sfr', dist.Normal((sfr_star*jnp.exp(-1.0*redshift/z_star)*(redshift/z_star)**alpha)-2.0, jnp.full(priors[0].nsrc, sfr_sig)))

        atten=numpyro.sample('atten',dist.TruncatedNormal(loc=sed_prior.params_mu[:, 2], scale=sed_prior.params_sig[:, 2],low=0.0))

        dust_alpha=numpyro.sample('dust_alpha',dist.TruncatedNormal(loc=sed_prior.params_mu[:, 3], scale=sed_prior.params_sig[:, 3],low=0.0))

        tau_main=numpyro.sample('tau_main',dist.Normal(sed_prior.params_mu[:, 4], sed_prior.params_sig[:, 4]))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_19 = sp_matmul(pointing_matrices[0], src_f[:, 18][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    # db_hat_20 = sp_matmul(pointing_matrices[1], src_f[:, 19][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    # db_hat_21 = sp_matmul(pointing_matrices[2], src_f[:, 20][:, None], priors[2].snpix).reshape(-1) + bkg[2]
    # db_hat_22 = sp_matmul(pointing_matrices[3], src_f[:, 21][:, None], priors[3].snpix).reshape(-1) + bkg[3]
    # db_hat_23 = sp_matmul(pointing_matrices[4], src_f[:, 22][:, None], priors[4].snpix).reshape(-1) + bkg[4]

    # for each band, condition on data
    with numpyro.plate('gep19_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_gep19", dist.Normal(db_hat_19, priors[0].snim),
                       obs=priors[0].sim)
    # with numpyro.plate('gep20_pixels', priors[1].snim.size):  # as ind_pmw:
    #     numpyro.sample("obs_gep20", dist.Normal(db_hat_20, priors[1].snim),
    #                    obs=priors[1].sim)
    # with numpyro.plate('gep21_pixels', priors[2].snim.size):  # as ind_plw:
    #     numpyro.sample("obs_gep21", dist.Normal(db_hat_21, priors[2].snim),
    #                    obs=priors[2].sim)
    # with numpyro.plate('gep22_pixels', priors[3].snim.size):  # as ind_plw:
    #     numpyro.sample("obs_gep22", dist.Normal(db_hat_22, priors[3].snim),
    #                    obs=priors[3].sim)
    # with numpyro.plate('gep23_pixels', priors[4].snim.size):  # as ind_plw:
    #     numpyro.sample("obs_gep23", dist.Normal(db_hat_23, priors[4].snim),
    #                    obs=priors[4].sim)

def GEP_CIGALE_schect_bands(priors, sed_prior, params,flux,flux_error):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

        # redshift-sfr relation parameters
    z_star = numpyro.sample('m', dist.TruncatedNormal(loc=params['z_star_mu'], scale=params['z_star_sig'], low=0.01))
    sfr_star = numpyro.sample('c',
                              dist.TruncatedNormal(loc=params['sfr_star_mu'], scale=params['sfr_star_sig'], low=0.01))
    alpha = params['alpha']

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    plate_sources=numpyro.plate('nsrc',priors[0].nsrc)

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with plate_sources:
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=sed_prior.params_mu[:, 1], scale=sed_prior.params_sig[:, 1],
                                                       low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        sfr = numpyro.sample('sfr', dist.Normal(
            (sfr_star * jnp.exp(-1.0 * redshift / z_star) * (redshift / z_star) ** alpha) - 2.0,
            jnp.full(priors[0].nsrc, sfr_sig)))

        atten = numpyro.sample('atten',
                               dist.TruncatedNormal(loc=sed_prior.params_mu[:, 2], scale=sed_prior.params_sig[:, 2],
                                                    low=0.0))

        dust_alpha = numpyro.sample('dust_alpha', dist.TruncatedNormal(loc=sed_prior.params_mu[:, 3],
                                                                       scale=sed_prior.params_sig[:, 3], low=0.0))

        tau_main=numpyro.sample('tau_main',dist.Normal(sed_prior.params_mu[:, 4], sed_prior.params_sig[:, 4]))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    with plate_sources:

    # for each band, condition on data
        numpyro.sample("obs_gep19", dist.Normal(src_f[:, 18], flux_error[0,:]),
                       obs=flux[0,:])
        numpyro.sample("obs_gep20", dist.Normal(src_f[:, 19], flux_error[1,:]),
                       obs=flux[1,:])
        numpyro.sample("obs_gep21", dist.Normal(src_f[:, 20], flux_error[2,:]),
                       obs=flux[2,:])
        numpyro.sample("obs_gep22", dist.Normal(src_f[:, 21], flux_error[3,:]),
                       obs=flux[3,:])
        numpyro.sample("obs_gep23", dist.Normal(src_f[:, 22], flux_error[4,:]),
                       obs=flux[4,:])

def GEP_CIGALE_bands(emulator,params_mu,params_sig,flux,flux_error):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    plate_sources=numpyro.plate('nsrc',params_mu.shape[0])

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with plate_sources:
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=params_mu[:, 1], scale=params_sig[:, 1],
                                                       low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        sfr = numpyro.sample('sfr', dist.Normal(loc=params_mu[:,0],scale=params_sig[:,0]))

        atten = numpyro.sample('atten',
                               dist.TruncatedNormal(loc=params_mu[:, 2], scale=params_sig[:, 2],
                                                    low=0.0))

        dust_alpha = numpyro.sample('dust_alpha', dist.TruncatedNormal(loc=params_mu[:, 3],
                                                                       scale=params_sig[:, 3], low=0.0))

        tau_main=numpyro.sample('tau_main',dist.Normal(params_mu[:, 4], params_sig[:, 4]))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(emulator['net_apply'](emulator['params'], params))

    with plate_sources:

    # for each band, condition on data
        numpyro.sample("obs_gep19", dist.Normal(src_f[:, 18], flux_error[0,:]),
                       obs=flux[0,:])
        numpyro.sample("obs_gep20", dist.Normal(src_f[:, 19], flux_error[1,:]),
                       obs=flux[1,:])
        numpyro.sample("obs_gep21", dist.Normal(src_f[:, 20], flux_error[2,:]),
                       obs=flux[2,:])
        numpyro.sample("obs_gep22", dist.Normal(src_f[:, 21], flux_error[3,:]),
                       obs=flux[3,:])
        numpyro.sample("obs_gep23", dist.Normal(src_f[:, 22], flux_error[4,:]),
                       obs=flux[4,:])

def GEP_CIGALE_schect_fixAGN(priors, sed_prior, params):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

        # redshift-sfr relation parameters
    z_star = numpyro.sample('m', dist.TruncatedNormal(loc=params['z_star_mu'], scale=params['z_star_sig'], low=0.01))
    sfr_star = numpyro.sample('c',
                              dist.TruncatedNormal(loc=params['sfr_star_mu'], scale=params['sfr_star_sig'], low=0.01))
    alpha = params['alpha']

    # sfr dispersion parameter
    sfr_sig = numpyro.sample('sfr_sig', dist.HalfNormal(params['sfr_disp']))

    # AGN priors
    atten = sed_prior.params_mu[:, 2]
    dust_alpha = sed_prior.params_mu[:, 3]
    tau_main= sed_prior.params_mu[:, 4]
    agn = sed_prior.params_mu[:, 5]

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=sed_prior.params_mu[:, 1], scale=sed_prior.params_sig[:, 1],
                                                       low=0.01))

        sfr = numpyro.sample('sfr', dist.Normal(
            (sfr_star * jnp.exp(-1.0 * redshift / z_star) * (redshift / z_star) ** alpha) - 2.0,
            jnp.full(priors[0].nsrc, sfr_sig)))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T

    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_19 = sp_matmul(pointing_matrices[0], src_f[:, 18][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_20 = sp_matmul(pointing_matrices[1], src_f[:, 19][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_21 = sp_matmul(pointing_matrices[2], src_f[:, 20][:, None], priors[2].snpix).reshape(-1) + bkg[2]
    db_hat_22 = sp_matmul(pointing_matrices[3], src_f[:, 21][:, None], priors[3].snpix).reshape(-1) + bkg[3]
    db_hat_23 = sp_matmul(pointing_matrices[4], src_f[:, 22][:, None], priors[4].snpix).reshape(-1) + bkg[4]

    # for each band, condition on data
    with numpyro.plate('gep19_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_gep19", dist.Normal(db_hat_19, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('gep20_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_gep20", dist.Normal(db_hat_20, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('gep21_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep21", dist.Normal(db_hat_21, priors[2].snim),
                       obs=priors[2].sim)
    with numpyro.plate('gep22_pixels', priors[3].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep22", dist.Normal(db_hat_22, priors[3].snim),
                       obs=priors[3].sim)
    with numpyro.plate('gep23_pixels', priors[4].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep23", dist.Normal(db_hat_23, priors[4].snim),
                       obs=priors[4].sim)

def GEP_CIGALE_schect_fixHyper(priors, sed_prior, params):
    """
    numpyro model for SPIRE maps using cigale emulator
    :param priors: list of xid+ SPIRE prior objects
    :type priors: list
    :param sed_prior: xid+ SED prior class
    :type sed_prior:
    :return:
    :rtype:
    """

    # get pointing matices in useable format
    pointing_matrices = [([p.amat_row, p.amat_col], p.amat_data) for p in priors]

    # get background priors for maps
    bkg_mu = np.asarray([p.bkg[0] for p in priors]).T
    bkg_sig = np.asarray([p.bkg[1] for p in priors]).T

    # background priors
    with numpyro.plate('bands', len(priors)):
        bkg = numpyro.sample('bkg', dist.Normal(bkg_mu, bkg_sig))

    # redshift-sfr relation parameters
    z_star =  params['z_star_mu']
    sfr_star = params['sfr_star_mu']
    alpha = params['alpha']
    # sfr dispersion parameter
    sfr_sig = params['sfr_disp']

    # sample parameters for each source (treat as conditionaly independent hence plate)
    with numpyro.plate('nsrc', priors[0].nsrc):
        # use truncated normal for redshift, with mean and sigma from prior
        redshift = numpyro.sample('redshift',
                                  dist.TruncatedNormal(loc=sed_prior.params_mu[:, 1], scale=sed_prior.params_sig[:, 1],
                                                       low=0.01))
        # use beta distribution for AGN as a fraction
        agn = numpyro.sample('agn', dist.Beta(1.0, 3.0))

        sfr = numpyro.sample('sfr', dist.Normal(
            (sfr_star * jnp.exp(-1.0 * redshift / z_star) * (redshift / z_star) ** alpha) - 2.0,
            jnp.full(priors[0].nsrc, sfr_sig)))

        atten = numpyro.sample('atten',
                               dist.TruncatedNormal(loc=sed_prior.params_mu[:, 2], scale=sed_prior.params_sig[:, 2],
                                                    low=0.0))

        dust_alpha = numpyro.sample('dust_alpha', dist.TruncatedNormal(loc=sed_prior.params_mu[:, 3],
                                                                       scale=sed_prior.params_sig[:, 3], low=0.0))

        tau_main=numpyro.sample('tau_main',dist.Normal(sed_prior.params_mu[:, 4], sed_prior.params_sig[:, 4]))

    # stack params and make vector ready to be used by emualator
    params = jnp.vstack((sfr[None, :], agn[None, :], redshift[None, :], atten[None,:],dust_alpha[None,:],tau_main[None,:])).T
    # Use emulator to get fluxes. As emulator provides log flux, convert.
    src_f = jnp.exp(sed_prior.emulator['net_apply'](sed_prior.emulator['params'], params))

    # create model map by multiplying fluxes by pointing matrix and adding background
    db_hat_19 = sp_matmul(pointing_matrices[0], src_f[:, 18][:, None], priors[0].snpix).reshape(-1) + bkg[0]
    db_hat_20 = sp_matmul(pointing_matrices[1], src_f[:, 19][:, None], priors[1].snpix).reshape(-1) + bkg[1]
    db_hat_21 = sp_matmul(pointing_matrices[2], src_f[:, 20][:, None], priors[2].snpix).reshape(-1) + bkg[2]
    db_hat_22 = sp_matmul(pointing_matrices[3], src_f[:, 21][:, None], priors[3].snpix).reshape(-1) + bkg[3]
    db_hat_23 = sp_matmul(pointing_matrices[4], src_f[:, 22][:, None], priors[4].snpix).reshape(-1) + bkg[4]

    # for each band, condition on data
    with numpyro.plate('gep19_pixels', priors[0].snim.size):  # as ind_psw:
        numpyro.sample("obs_gep19", dist.Normal(db_hat_19, priors[0].snim),
                       obs=priors[0].sim)
    with numpyro.plate('gep20_pixels', priors[1].snim.size):  # as ind_pmw:
        numpyro.sample("obs_gep20", dist.Normal(db_hat_20, priors[1].snim),
                       obs=priors[1].sim)
    with numpyro.plate('gep21_pixels', priors[2].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep21", dist.Normal(db_hat_21, priors[2].snim),
                       obs=priors[2].sim)
    with numpyro.plate('gep22_pixels', priors[3].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep22", dist.Normal(db_hat_22, priors[3].snim),
                       obs=priors[3].sim)
    with numpyro.plate('gep23_pixels', priors[4].snim.size):  # as ind_plw:
        numpyro.sample("obs_gep23", dist.Normal(db_hat_23, priors[4].snim),
                       obs=priors[4].sim)


text:
declare namespace Reflect {
    function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
    function construct(target: Function, argumentsList: ArrayLike<any>, newTarget?: any): any;
    function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
    function deleteProperty(target: object, propertyKey: PropertyKey): boolean;
    function get(target: object, propertyKey: PropertyKey, receiver?: any): any;
    function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor;
    function getPrototypeOf(target: object): object;
    function has(target: object, propertyKey: PropertyKey): boolean;
    function isExtensible(target: object): boolean;
    function ownKeys(target: object): Array<PropertyKey>;
    function preventExtensions(target: object): boolean;
    function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean;
    function setPrototypeOf(target: object, proto: any): boolean;
}


text:
package org.onosproject.net;

public final class OsgiPropertyConstants {
    private OsgiPropertyConstants() {
    }

    public static final String USE_REGION_FOR_BALANCE_ROLES = "useRegionForBalanceRoles";
    public static final boolean USE_REGION_FOR_BALANCE_ROLES_DEFAULT = false;

    public static final String REBALANCE_ROLES_ON_UPGRADE = "rebalanceRolesOnUpgrade";
    public static final boolean REBALANCE_ROLES_ON_UPGRADE_DEFAULT = true;

    public static final String SHARED_THREAD_POOL_SIZE = "sharedThreadPoolSize";
    public static final int SHARED_THREAD_POOL_SIZE_DEFAULT = 30;

    public static final String MAX_EVENT_TIME_LIMIT = "maxEventTimeLimit";
    public static final int MAX_EVENT_TIME_LIMIT_DEFAULT = 2000;

    public static final String CALCULATE_PERFORMANCE_CHECK = "sharedThreadPerformanceCheck";
    public static final boolean CALCULATE_PERFORMANCE_CHECK_DEFAULT = false;

    public static final String ALLOW_EXTRANEOUS_RULES = "allowExtraneousRules";
    public static final boolean ALLOW_EXTRANEOUS_RULES_DEFAULT = false;

    public static final String IMPORT_EXTRANEOUS_RULES = "importExtraneousRules";
    public static final boolean IMPORT_EXTRANEOUS_RULES_DEFAULT = false;

    public static final String PURGE_ON_DISCONNECTION = "purgeOnDisconnection";
    public static final boolean PURGE_ON_DISCONNECTION_DEFAULT = false;

    public static final String POLL_FREQUENCY = "fallbackFlowPollFrequency";
    public static final int POLL_FREQUENCY_DEFAULT = 30;

    public static final String FOM_NUM_THREADS = "numThreads";
    public static final int FOM_NUM_THREADS_DEFAULT = 4;

    public static final String GM_POLL_FREQUENCY = "fallbackGroupPollFrequency";
    public static final int GM_POLL_FREQUENCY_DEFAULT = 30;

    public static final String GM_PURGE_ON_DISCONNECTION = "purgeOnDisconnection";
    public static final boolean  GM_PURGE_ON_DISCONNECTION_DEFAULT = false;

    public static final String HM_ALLOW_DUPLICATE_IPS = "allowDuplicateIps";
    public static final boolean HM_ALLOW_DUPLICATE_IPS_DEFAULT = true;

    public static final String HM_MONITOR_HOSTS = "monitorHosts";
    public static final boolean HM_MONITOR_HOSTS_DEFAULT = false;

    public static final String HM_PROBE_RATE = "probeRate";
    public static final long HM_PROBE_RATE_DEFAULT = 30000;

    public static final String HM_HOST_MOVE_TRACKER_ENABLE = "hostMoveTrackerEnabled";
    public static final boolean HM_HOST_MOVE_TRACKER_ENABLE_DEFAULT = false;

    public static final String HM_HOST_MOVED_THRESHOLD_IN_MILLIS = "hostMoveThresholdInMillis";
    public static final int HM_HOST_MOVED_THRESHOLD_IN_MILLIS_DEFAULT = 200000;

    public static final String HM_HOST_MOVE_COUNTER = "hostMoveCounter";
    public static final int HM_HOST_MOVE_COUNTER_DEFAULT = 3;

    public static final String HM_OFFENDING_HOST_EXPIRY_IN_MINS = "offendingHostExpiryInMins";
    public static final long HM_OFFENDING_HOST_EXPIRY_IN_MINS_DEFAULT = 1;

    public static final String HM_OFFENDING_HOST_THREADS_POOL_SIZE = "offendingHostClearThreadPool";
    public static final int HM_OFFENDING_HOST_THREADS_POOL_SIZE_DEFAULT = 10;

    public static final String HM_GREEDY_LEARNING_IPV6 = "greedyLearningIpv6";
    public static final boolean HM_GREEDY_LEARNING_IPV6_DEFAULT = false;

    public static final String ICR_USE_FLOW_OBJECTIVES = "useFlowObjectives";
    public static final boolean ICR_USE_FLOW_OBJECTIVES_DEFAULT = false;

    public static final String ICR_LABEL_SELECTION = "labelSelection";
    public static final String ICR_LABEL_SELECTION_DEFAULT = "RANDOM";

    public static final String ICR_OPT_LABEL_SELECTION = "optLabelSelection";
    public static final String ICR_OPT_LABEL_SELECTION_DEFAULT = "NONE";

    public static final String ICR_FLOW_OPTIMIZATION = "optimizeInstructions";
    public static final boolean ICR_FLOW_OPTIMIZATION_DEFAULT = false;

    public static final String ICR_COPY_TTL = "useCopyTtl";
    public static final boolean ICR_COPY_TTL_DEFAULT = false;

    public static final String ICU_ENABLED = "enabled";
    public static final boolean ICU_ENABLED_DEFAULT = true;

    public static final String ICU_PERIOD = "period";
    public static final int ICU_PERIOD_DEFAULT = 5; //seconds

    public static final String ICU_RETRY_THRESHOLD = "retryThreshold";
    public static final int ICU_RETRY_THRESHOLD_DEFAULT = 5; //tries

    public static final String NON_DISRUPTIVE_INSTALLATION_WAITING_TIME = "nonDisruptiveInstallationWaitingTime";
    public static final int NON_DISRUPTIVE_INSTALLATION_WAITING_TIME_DEFAULT = 1;

    public static final String IM_SKIP_RELEASE_RESOURCES_ON_WITHDRAWAL = "skipReleaseResourcesOnWithdrawal";
    public static final boolean IM_SKIP_RELEASE_RESOURCES_ON_WITHDRAWAL_DEFAULT = false;

    public static final String IM_NUM_THREADS = "numThreads";
    public static final int IM_NUM_THREADS_DEFAULT = 12;

    public static final String MM_NUM_THREADS = "numThreads";
    public static final int MM_NUM_THREADS_DEFAULT = 12;

    public static final String MM_FALLBACK_METER_POLL_FREQUENCY = "fallbackMeterPollFrequency";
    public static final int MM_FALLBACK_METER_POLL_FREQUENCY_DEFAULT = 30;

    public static final String MM_PURGE_ON_DISCONNECTION = "purgeOnDisconnection";
    public static final boolean MM_PURGE_ON_DISCONNECTION_DEFAULT = false;

    public static final String NRM_ARP_ENABLED = "arpEnabled";
    public static final boolean NRM_ARP_ENABLED_DEFAULT = true;

    public static final String NRM_NDP_ENABLED = "ndpEnabled";
    public static final boolean NRM_NDP_ENABLED_DEFAULT = false;

    public static final String NRM_REQUEST_INTERCEPTS_ENABLED = "requestInterceptsEnabled";
    public static final boolean NRM_REQUEST_INTERCEPTS_ENABLED_DEFAULT = true;

    public static final String PWM_PROBE_INTERVAL = "probeInterval";
    public static final int PWM_PROBE_INTERVAL_DEFAULT = 15;

    public static final String DTP_MAX_EVENTS = "maxEvents";
    public static final int DTP_MAX_EVENTS_DEFAULT = 1000;

    public static final String DTP_MAX_IDLE_MS = "maxIdleMs";
    public static final int DTP_MAX_IDLE_MS_DEFAULT = 10;

    public static final String DTP_MAX_BATCH_MS = "maxBatchMs";
    public static final int DTP_MAX_BATCH_MS_DEFAULT = 50;

    public static final String AUDIT_ENABLED = "auditEnabled";
    public static final boolean AUDIT_ENABLED_DEFAULT = false;

    public static final String AUDIT_LOGGER = "auditLogger";
    public static final String AUDIT_LOGGER_DEFAULT = "securityAudit";

    public static final String FOM_ACCUMULATOR_MAX_OBJECTIVES = "accumulatorMaxObjectives";
    public static final int FOM_ACCUMULATOR_MAX_OBJECTIVES_DEFAULT = 1000;

    public static final String FOM_ACCUMULATOR_MAX_IDLE_MILLIS = "accumulatorMaxIdleMillis";
    public static final int FOM_ACCUMULATOR_MAX_IDLE_MILLIS_DEFAULT = 10;

    public static final String FOM_ACCUMULATOR_MAX_BATCH_MILLIS = "accumulatorMaxBatchMillis";
    public static final int FOM_ACCUMULATOR_MAX_BATCH_MILLIS_DEFAULT = 500;

}


text:
        <form role="search" method="get" id="searchform" action="{{site.baseurl}}/search/">

                    <input type="text" value="" name="query" id="s" />

        </form>

Recent Posts

                How to Specialize – Web Development Niche

                This and Bind in React

                WordPress LAMP setup on Digital Ocean

                Debugging Three.js

                How to Shorten Title Length in WordPress


text:
/**
 */
package MatchModel.impl;

import MatchModel.Contender;
import MatchModel.Hero;
import MatchModel.HeroPool;
import MatchModel.Match;
import MatchModel.MatchModelFactory;
import MatchModel.MatchModelPackage;
import MatchModel.Player;
import MatchModel.PlayerGroup;
import MatchModel.Side;
import MatchModel.Team;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;

import org.eclipse.emf.ecore.impl.EPackageImpl;

/**
 *
 * An implementation of the model Package.
 *
 * @generated
 */
public class MatchModelPackageImpl extends EPackageImpl implements MatchModelPackage {
	/**
	 *
	 *
	 * @generated
	 */
	private EClass playerGroupEClass = null;

	/**
	 *
	 *
	 * @generated
	 */
	private EClass playerEClass = null;

	/**
	 *
	 *
	 * @generated
	 */
	private EClass matchEClass = null;

	/**
	 *
	 *
	 * @generated
	 */
	private EClass heroEClass = null;

	/**
	 *
	 *
	 * @generated
	 */
	private EClass contenderEClass = null;

	/**
	 *
	 *
	 * @generated
	 */
	private EClass teamEClass = null;

	/**
	 *
	 *
	 * @generated
	 */
	private EClass heroPoolEClass = null;

	/**
	 *
	 *
	 * @generated
	 */
	private EEnum sideEEnum = null;

	/**
	 * Creates an instance of the model Package, registered with
	 * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
	 * package URI value.
	 *
Note: the correct way to create the package is via the static
	 * factory method {@link #init init()}, which also performs
	 * initialization of the package, or returns the registered package,
	 * if one already exists.
	 *
	 *
	 * @see org.eclipse.emf.ecore.EPackage.Registry
	 * @see MatchModel.MatchModelPackage#eNS_URI
	 * @see #init()
	 * @generated
	 */
	private MatchModelPackageImpl() {
		super(eNS_URI, MatchModelFactory.eINSTANCE);
	}

	/**
	 *
	 *
	 * @generated
	 */
	private static boolean isInited = false;

	/**
	 * Creates, registers, and initializes the Package for this model, and for any others upon which it depends.
	 *
	 *
This method is used to initialize {@link MatchModelPackage#eINSTANCE} when that field is accessed.
	 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
	 *
	 *
	 * @see #eNS_URI
	 * @see #createPackageContents()
	 * @see #initializePackageContents()
	 * @generated
	 */
	public static MatchModelPackage init() {
		if (isInited) return (MatchModelPackage)EPackage.Registry.INSTANCE.getEPackage(MatchModelPackage.eNS_URI);

		// Obtain or create and register package
		MatchModelPackageImpl theMatchModelPackage = (MatchModelPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof MatchModelPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new MatchModelPackageImpl());

		isInited = true;

		// Create package meta-data objects
		theMatchModelPackage.createPackageContents();

		// Initialize created meta-data
		theMatchModelPackage.initializePackageContents();

		// Mark meta-data to indicate it can't be changed
		theMatchModelPackage.freeze();

		// Update the registry and return the package
		EPackage.Registry.INSTANCE.put(MatchModelPackage.eNS_URI, theMatchModelPackage);
		return theMatchModelPackage;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EClass getPlayerGroup() {
		return playerGroupEClass;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EReference getPlayerGroup_Players() {
		return (EReference)playerGroupEClass.getEStructuralFeatures().get(0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EClass getPlayer() {
		return playerEClass;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EAttribute getPlayer_Name() {
		return (EAttribute)playerEClass.getEStructuralFeatures().get(0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EAttribute getPlayer_Id() {
		return (EAttribute)playerEClass.getEStructuralFeatures().get(1);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EReference getPlayer_Matches() {
		return (EReference)playerEClass.getEStructuralFeatures().get(2);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EClass getMatch() {
		return matchEClass;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EAttribute getMatch_Id() {
		return (EAttribute)matchEClass.getEStructuralFeatures().get(0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EAttribute getMatch_Winner() {
		return (EAttribute)matchEClass.getEStructuralFeatures().get(1);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EReference getMatch_Radiant() {
		return (EReference)matchEClass.getEStructuralFeatures().get(2);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EReference getMatch_Dire() {
		return (EReference)matchEClass.getEStructuralFeatures().get(3);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EClass getHero() {
		return heroEClass;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EAttribute getHero_Id() {
		return (EAttribute)heroEClass.getEStructuralFeatures().get(0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EAttribute getHero_Name() {
		return (EAttribute)heroEClass.getEStructuralFeatures().get(1);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EAttribute getHero_ImagePath() {
		return (EAttribute)heroEClass.getEStructuralFeatures().get(2);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EClass getContender() {
		return contenderEClass;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EReference getContender_Hero() {
		return (EReference)contenderEClass.getEStructuralFeatures().get(0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EReference getContender_Player() {
		return (EReference)contenderEClass.getEStructuralFeatures().get(1);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EClass getTeam() {
		return teamEClass;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EReference getTeam_Contenders() {
		return (EReference)teamEClass.getEStructuralFeatures().get(0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EClass getHeroPool() {
		return heroPoolEClass;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EReference getHeroPool_Heroes() {
		return (EReference)heroPoolEClass.getEStructuralFeatures().get(0);
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EEnum getSide() {
		return sideEEnum;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public MatchModelFactory getMatchModelFactory() {
		return (MatchModelFactory)getEFactoryInstance();
	}

	/**
	 *
	 *
	 * @generated
	 */
	private boolean isCreated = false;

	/**
	 * Creates the meta-model objects for the package.  This method is
	 * guarded to have no affect on any invocation but its first.
	 *
	 *
	 * @generated
	 */
	public void createPackageContents() {
		if (isCreated) return;
		isCreated = true;

		// Create classes and their features
		playerGroupEClass = createEClass(PLAYER_GROUP);
		createEReference(playerGroupEClass, PLAYER_GROUP__PLAYERS);

		playerEClass = createEClass(PLAYER);
		createEAttribute(playerEClass, PLAYER__NAME);
		createEAttribute(playerEClass, PLAYER__ID);
		createEReference(playerEClass, PLAYER__MATCHES);

		matchEClass = createEClass(MATCH);
		createEAttribute(matchEClass, MATCH__ID);
		createEAttribute(matchEClass, MATCH__WINNER);
		createEReference(matchEClass, MATCH__RADIANT);
		createEReference(matchEClass, MATCH__DIRE);

		heroEClass = createEClass(HERO);
		createEAttribute(heroEClass, HERO__ID);
		createEAttribute(heroEClass, HERO__NAME);
		createEAttribute(heroEClass, HERO__IMAGE_PATH);

		contenderEClass = createEClass(CONTENDER);
		createEReference(contenderEClass, CONTENDER__HERO);
		createEReference(contenderEClass, CONTENDER__PLAYER);

		teamEClass = createEClass(TEAM);
		createEReference(teamEClass, TEAM__CONTENDERS);

		heroPoolEClass = createEClass(HERO_POOL);
		createEReference(heroPoolEClass, HERO_POOL__HEROES);

		// Create enums
		sideEEnum = createEEnum(SIDE);
	}

	/**
	 *
	 *
	 * @generated
	 */
	private boolean isInitialized = false;

	/**
	 * Complete the initialization of the package and its meta-model.  This
	 * method is guarded to have no affect on any invocation but its first.
	 *
	 *
	 * @generated
	 */
	public void initializePackageContents() {
		if (isInitialized) return;
		isInitialized = true;

		// Initialize package
		setName(eNAME);
		setNsPrefix(eNS_PREFIX);
		setNsURI(eNS_URI);

		// Create type parameters

		// Set bounds for type parameters

		// Add supertypes to classes

		// Initialize classes, features, and operations; add parameters
		initEClass(playerGroupEClass, PlayerGroup.class, "PlayerGroup", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEReference(getPlayerGroup_Players(), this.getPlayer(), null, "players", null, 1, 5, PlayerGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(playerEClass, Player.class, "Player", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEAttribute(getPlayer_Name(), ecorePackage.getEString(), "name", null, 0, 1, Player.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getPlayer_Id(), ecorePackage.getELong(), "id", null, 0, 1, Player.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getPlayer_Matches(), this.getMatch(), null, "matches", null, 0, -1, Player.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(matchEClass, Match.class, "Match", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEAttribute(getMatch_Id(), ecorePackage.getELong(), "id", null, 0, 1, Match.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getMatch_Winner(), this.getSide(), "winner", "UNKNOWN", 0, 1, Match.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getMatch_Radiant(), this.getTeam(), null, "radiant", null, 1, 1, Match.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getMatch_Dire(), this.getTeam(), null, "dire", null, 1, 1, Match.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(heroEClass, Hero.class, "Hero", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEAttribute(getHero_Id(), ecorePackage.getEInt(), "id", null, 0, 1, Hero.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
		initEAttribute(getHero_Name(), ecorePackage.getEString(), "name", null, 0, 1, Hero.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEAttribute(getHero_ImagePath(), ecorePackage.getEString(), "imagePath", null, 0, 1, Hero.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(contenderEClass, Contender.class, "Contender", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEReference(getContender_Hero(), this.getHero(), null, "hero", null, 1, 1, Contender.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
		initEReference(getContender_Player(), this.getPlayer(), null, "player", null, 0, 1, Contender.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(teamEClass, Team.class, "Team", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEReference(getTeam_Contenders(), this.getContender(), null, "contenders", null, 5, 5, Team.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		initEClass(heroPoolEClass, HeroPool.class, "HeroPool", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
		initEReference(getHeroPool_Heroes(), this.getHero(), null, "heroes", null, 0, -1, HeroPool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

		// Initialize enums and add enum literals
		initEEnum(sideEEnum, Side.class, "Side");
		addEEnumLiteral(sideEEnum, Side.RADIANT);
		addEEnumLiteral(sideEEnum, Side.DIRE);
		addEEnumLiteral(sideEEnum, Side.UNKNOWN);

		// Create resource
		createResource(eNS_URI);
	}

} //MatchModelPackageImpl