<commit_before>import pyregion
import pyfits
import numpy as np
import pywcs
from agpy.region_positions import *

def get_fluxes(regfile, outfile, inneraprad=35, outeraprad=60, hdu=None, PPBEAM=1.0, debug=False, print_nulls=False):
    """
    Extract fluxes from a region-defined aperture with inner and outer circular apertures
    specififed

    MUST BE IN GALACTIC COORDINATES
    """
    if hdu is None:
        raise ValueError("hdu keyword is required")

    data = hdu.data
    header = hdu.header
    wcs = pywcs.WCS(header)
    glonmax = wcs.wcs_pix2sky(0,0,0)[0]
    glonmin = wcs.wcs_pix2sky(data.shape[1],0,0)[1]

    reglist = pyregion.open(regfile)

    outf = open(outfile,'w')

    print "".join("%16s" % s for s in ['Source_Name','SumJy','ApSumJy','MeanApSumJy','SumJyBm','ApSumJyBm','BgMed','BgMean','BgStd','FracErrBg'])
    print >>outf,"".join("%16s" % s for s in ['Source_Name','SumJy','ApSumJy','MeanApSumJy','SumJyBm','ApSumJyBm','BgMed','BgMean','BgStd','FracErrBg'])

    for reg in reglist:
        glon,glat = position_region(reg).galactic()
        if not((glon > glonmin) and (glon < glonmax)):
            # these are the limits of the survey
            if print_nulls:<commit_msg>pyfits -> astropy<commit_after>try:
    import astropy.wcs as pywcs
    import astropy.io.fits as pyfits
except ImportError:
    import pyfits
    import pywcs
import numpy as np
import pyregion
from agpy.region_positions import *

def get_fluxes(regfile, outfile, inneraprad=35, outeraprad=60, hdu=None, PPBEAM=1.0, debug=False, print_nulls=False):
    """
    Extract fluxes from a region-defined aperture with inner and outer circular apertures
    specififed

    MUST BE IN GALACTIC COORDINATES
    """
    if hdu is None:
        raise ValueError("hdu keyword is required")

    data = hdu.data
    header = hdu.header
    wcs = pywcs.WCS(header)
    glonmax = wcs.wcs_pix2sky(0,0,0)[0]
    glonmin = wcs.wcs_pix2sky(data.shape[1],0,0)[1]

    reglist = pyregion.open(regfile)

    outf = open(outfile,'w')

    print "".join("%16s" % s for s in ['Source_Name','SumJy','ApSumJy','MeanApSumJy','SumJyBm','ApSumJyBm','BgMed','BgMean','BgStd','FracErrBg'])
    print >>outf,"".join("%16s" % s for s in ['Source_Name','SumJy','ApSumJy','MeanApSumJy','SumJyBm','ApSumJyBm','BgMed','BgMean','BgStd','FracErrBg'])

    for reg in reglist:
        glon,glat = position_region(reg).galactic()
        if not((glon > glonmin) and (glon < glonmax)):
            # these are the limits of the survey
            if print_nulls:
{'fraction_non_alphanumeric': 0.1391955835962145, 'fraction_numerical': 0.015772870662460567, 'mean_word_length': 3.8416030534351147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3606013', 'n_tokens_mistral': 994, 'n_tokens_neox': 912, 'n_words': 207}