# Path: ugali/utils/fileio.py
# def read(filename,**kwargs):
# def write(filename,data,**kwargs):
# def check_formula(formula):
# def parse_formula(formula):
# def add_column(filename,column,formula,force=False):
# def load_header(kwargs):
# def load_headers(filenames,multiproc=False,**kwargs):
# def load_file(kwargs):
# def load_files(filenames,multiproc=False,**kwargs):
# def load(args):
# def load_infiles(infiles,columns=None,multiproc=False):
# def insert_columns(filename,data,ext=1,force=False,colnum=None):
# def write_fits(filename,data,header=None,force=False):
# 
# Path: ugali/utils/logger.py
# class SpecialFormatter(logging.Formatter):
#     FORMATS = {'DEFAULT'       : "%(message)s",
#                logging.WARNING : "WARNING: %(message)s",
#                logging.ERROR   : "ERROR: %(message)s"}
#     def format(self, record):
# def file_found(filename,force):


from collections import OrderedDict as odict
from ugali.utils import fileio
from ugali.utils.logger import logger
import numpy
import numpy as np
import healpy as hp
import fitsio
import ugali.utils.projector
import ugali.utils.fileio
    import fitsio
    import fitsio
    import fitsio
    import fitsio
    import fitsio
    import argparse
        raise Exception(msg)

    if fullsky and not np.isscalar(column):
        raise Exception("Cannot make fullsky map from list of columns.")
    
    if fullsky:
        shape = list(value.shape)
        shape[0] = npix
        hpxmap = hp.UNSEEN * np.ones(shape,dtype=value.dtype)
        hpxmap[pix] = value
        return (nside,pix,hpxmap.T)
    else:
        return (nside,pix,value.T)

def merge_partial_maps(filenames,outfile,**kwargs):
    """
    Parameters:
    -----------
    filenames : list of filenames to merge
    outfile   : name of outfile to create
    kwargs    : kwargs passed to fitsio.read

    Returns:
    --------
    None
    """
    filenames = np.atleast_1d(filenames)

    header = fitsio.read_header(filenames[0],ext=kwargs.get('ext',1))
    nside = header['NSIDE']

# Path: ugali/utils/fileio.py
# def read(filename,**kwargs):
# def write(filename,data,**kwargs):
# def check_formula(formula):
# def parse_formula(formula):
# def add_column(filename,column,formula,force=False):
# def load_header(kwargs):
# def load_headers(filenames,multiproc=False,**kwargs):
# def load_file(kwargs):
# def load_files(filenames,multiproc=False,**kwargs):
# def load(args):
# def load_infiles(infiles,columns=None,multiproc=False):
# def insert_columns(filename,data,ext=1,force=False,colnum=None):
# def write_fits(filename,data,header=None,force=False):
# 
# Path: ugali/utils/logger.py
# class SpecialFormatter(logging.Formatter):
#     FORMATS = {'DEFAULT'       : "%(message)s",
#                logging.WARNING : "WARNING: %(message)s",
#                logging.ERROR   : "ERROR: %(message)s"}
#     def format(self, record):
# def file_found(filename,force):


# Path: ugali/utils/healpix.py
from collections import OrderedDict as odict
from ugali.utils import fileio
from ugali.utils.logger import logger
import numpy
import numpy as np
import healpy as hp
import fitsio
import ugali.utils.projector
import ugali.utils.fileio
    import fitsio
    import fitsio
    import fitsio
    import fitsio
    import fitsio
    import argparse

        raise Exception(msg)

    if fullsky and not np.isscalar(column):
        raise Exception("Cannot make fullsky map from list of columns.")
    
    if fullsky:
        shape = list(value.shape)
        shape[0] = npix
        hpxmap = hp.UNSEEN * np.ones(shape,dtype=value.dtype)
        hpxmap[pix] = value
        return (nside,pix,hpxmap.T)
    else:
        return (nside,pix,value.T)

def merge_partial_maps(filenames,outfile,**kwargs):
    """
    Parameters:
    -----------
    filenames : list of filenames to merge
    outfile   : name of outfile to create
    kwargs    : kwargs passed to fitsio.read

    Returns:
    --------
    None
    """
    filenames = np.atleast_1d(filenames)

    header = fitsio.read_header(filenames[0],ext=kwargs.get('ext',1))
    nside = header['NSIDE']

    data = fileio.load_files(filenames,**kwargs)