clusex.lib package

Submodules

clusex.lib.cgpng module

class clusex.lib.cgpng.GUI(master, png_paths, pngfile_out, include_header=False, extensiones=('.png', '.jpg', '.jpeg'))[source]

Bases: object

ask_quit()[source]
classify(selected_class)[source]
display_image(path)[source]
on_enter(event)[source]
on_leave(event)[source]
skip_image()[source]
undo_last()[source]
update_image_display()[source]
clusex.lib.cgpng.cgPNG(img_folder, tsv_out, include_header=False)[source]
clusex.lib.cgpng.natural_key(s: str)[source]

Human sorting: img2, img10 -> 2, 10.

clusex.lib.check module

clusex.lib.check.CheckFlag(val, check)[source]

Check for flag contained in $val, returns 1 if found

clusex.lib.check.CheckKron(xpos, ypos, x, y, R, theta, q)[source]

check if position is inside of the Kron Ellipse saturaded region returns True if object center is in Ellipse region

clusex.lib.check.CheckSatReg2(x, y, filein)[source]

Check if object is inside of saturated region. returns True if at least one pixel is inside

clusex.lib.check.GetAxis(Image)[source]

Get number of rows and columns from the image

clusex.lib.check.GetCounts(Image)[source]

Get Counts from Image

clusex.lib.check.GetWCS(Image)[source]

Get World Cordinate System info

clusex.lib.classify_galaxies module

clusex.lib.ds9 module

clusex.lib.ds9.ds9kron(sexfile, regfile, scale, offset)[source]

Creates ds9 region file to check output catalog

clusex.lib.galaxypng module

Created on Mon Apr 28 16:13:00 2025

@author: samnay

clusex.lib.galaxypng.DesiFromSexCat(sexcat='hotcold.cat', output_dir='desi_images', scale=1, offset=0, desi_pixscale=0.262, image_plate=0.68, max_mag=18, starclass=0.6, sdss=False)[source]
clusex.lib.galaxypng.GetSize(x, y, R, theta, ell)[source]

this subroutine get the maximun

clusex.lib.getdesi module

class clusex.lib.getdesi.DownImage(ra, dec, scale=0.3515625, width=512, height=512, savename=None, sdss=False)[source]

Bases: object

Class for an DESI/SDSS png image.

RA, DEC - J2000, degrees SCALE - plate scale in arsec per pixel WIDTH, HEIGHT - size of image in pixels SAVENAME - if none provided, defaults to ‘object.jpg’ DR - integer value for SDSS data release.

downloadDESI()[source]
downloadSDSS()[source]
show()[source]
clusex.lib.getdesi.desiList(file, scale=0.262, width=512, height=512, show=False, sdss=False)[source]
clusex.lib.getdesi.desiListParser()[source]

Function for argument parsing

clusex.lib.getdesi.simg(ra=37.228, dec=0.37, scale=0.396, width=512, height=512, savename=None, show=True, sdss=False)[source]

Get jpg image, view it, and remove temporary jpg file.

clusex.lib.init module

class clusex.lib.init.Params[source]

Bases: object

SexArSort = 'sortar.cat'
at1 = 1
at2 = 1
bf1 = 1
bf2 = 1
bs1 = 1
bs2 = 1
create = 0
da1 = 1
da2 = 1
dm1 = 1
dm2 = 1
dn1 = 1
dn2 = 1
dt1 = 1
dt2 = 1
flagDs9 = 1
flagminrad = False
gain = 10
image = 'none.fits'
joinscale = 0.7
minrad = 10
minsatsize = 10
offset = 0
outcold = 'cold.sex'
outhot = 'hot.sex'
output = 'hc.cat'
output2 = 'hotcold.cat'
plate = 1
red = 0.3
regoutfile = 'hotcold.reg'
run1 = 1
run2 = 1
satfileout = 'sat.reg'
satlevel = 100000
satmethod = 3
satoffset = 1
satq = 0.1
satscale = 1
scale = 1
scalecor = 1
seeing = 2
sexfile = 'default.sex'
tol = 0.5
zpt = 25
clusex.lib.init.printWelcome()[source]

clusex.lib.join module

clusex.lib.join.joinsexcat(maincat, secondcat, output, JoinScale, incFlag=False, red=0.1, minrad=5)[source]

merges two Sextractor catalogs

clusex.lib.join.putFlagSat(sexfile, sexfile2, regfile)[source]

Put flags on objects which are inside saturated regions

clusex.lib.joinfiles module

clusex.lib.joinfiles.extrae_id(path: str) int[source]

Extract the ID from namefile: imagen_0004.png -> 4. returns ValueError if it is not found.

clusex.lib.joinfiles.joinclass(archivo1, archivo2, salida)[source]

clusex.lib.make module

clusex.lib.make.CatArSort(SexCat, scale, offset, SexArSort, NCol, NRow)[source]
clusex.lib.make.EraseObjectMask(MaskFile, tempMask, obj, fill=0)[source]
clusex.lib.make.EraseObjectMask2(maskimg, obj)[source]
clusex.lib.make.GetPng(data, counts, wcs, dpi=200, cmap='gray_r', namepng='obj.png', bri=33, con=0.98)[source]

Converts image into a PNG image with axis coordinates, inverted colormap, log/zmax style

clusex.lib.make.GetSize(x, y, R, theta, ell, ncol, nrow)[source]

this subroutine get the maximun

clusex.lib.make.MakeImage(newfits, sizex, sizey)[source]

create a new blank Image

clusex.lib.make.MakeKron(imagemat, idn, x, y, R, theta, ell, xmin, xmax, ymin, ymax)[source]

This subroutine create a Kron ellipse within a box defined by: xmin, xmax, ymin, ymax

clusex.lib.make.MakeMask(maskimage, catfile, scale, offset, regfile)[source]

Create a mask image using ellipses for every Object of catfile. Now includes offset

clusex.lib.make.MakeObjImg(image, mask)[source]

make object image

clusex.lib.make.MakeSatBox(maskimage, region, val, ncol, nrow)[source]

Create a mask for saturated regions

clusex.lib.make.MakeStamps(image, catalog, maskimage, stretch, skyoff, dpi, cmap, scale, offset, bright, contrast, frac, fracmax, galclass)[source]
clusex.lib.make.ShowImg(img: array, xc: int, yc: int, wcs, namepng='obj.png', dpival=100, sky=1, cmap='viridis', bri=0, con=1, frac=1, fracmax=1)[source]

This routine shows the image

clusex.lib.maskellipse module

clusex.lib.maskellipse.applyMask(img_path, number, a, b, theta_deg, outdir)[source]
clusex.lib.maskellipse.extrae_id(path: str) int[source]

Extract ID number from file path imagen_0004.png -> 4. returns ValueError if number is not found

clusex.lib.maskellipse.maskImage(sexcat, paths, scale, offset, desi_pixscale, image_plate, out_dir)[source]

clusex.lib.radcor module

class clusex.lib.radcor.RadMod(sexcat1: str, sexcat2: str, newcat: str, tol=1, red=1, minrad=10, scalecor=1)[source]

Bases: object

CheckFlag(val: int, check: int) bool[source]

Check for flag contained in val, returns True if found

clusex.lib.read module

clusex.lib.read.read_config(confile)[source]
clusex.lib.read.readcon(params, confile)[source]

clusex.lib.satbox module

class clusex.lib.satbox.SatBox(params: object)[source]

Bases: object

AbsorbSmallBox(xx, yy, sx, sy, N)[source]

Removes small boxes inside big boxes

AreTwoBoxSame(xx1, yy1, sx1, sy1, xx2, yy2, sx2, sy2)[source]

Check if two boxes are the same

BoxCenterInPoint(xx, yy, xmin, xmax, ymin, ymax)[source]
BoxCorners2Side(xmin, xmax, ymin, ymax)[source]
BoxSide2Corners(X, Y, sidex, sidey)[source]
CheckFlag(val, check)[source]

Check for flag contained in $val, returns True if found

CheckSatReg2(x, y, filein)[source]

Check if object is inside of saturated region. returns True if at least one pixel is inside

CorrectCorners(xmin, xmax, ymin, ymax, imaxx, imaxy)[source]
Ds9SatBox(image, satfileout, sexcat, satscale, satoffset, satlevel, minsatsize, method, satq=0.5)[source]

Creates a file for ds9 which selects bad saturated regions

GetAxis(Image)[source]

Get number of rows and columns from the image

GetMaxCor(image, xmin, xmax, ymin, ymax)[source]

Get coordinate (x,y) where the max value in counts

GetMaxCor2(image, xmin, xmax, ymin, ymax)[source]

Get coordinate (x,y) where the max value in counts. Avoids negative pixels

GetSatBox(image, satfileout, sexcat, satlevel, minsatsize, satq)[source]

Obtains the saturated boxes from the sextractor catalog

IncludeBoxCenterInPoint(xx, yy, xmin, xmax, ymin, ymax)[source]

combines the two methods

IncludePointInBox(xx, yy, xmin, xmax, ymin, ymax)[source]
IsBoxInBox(xx1, yy1, sx1, sy1, xx2, yy2, sx2, sy2)[source]

Check if box is inside another box

IsPointInBox(xx, yy, xmin, xmax, ymin, ymax)[source]
RemoveDupBox(xx, yy, sx, sy, N)[source]

Removes duplicated boxes and small boxes inside big boxes

ResizeBox(xx, yy, sx, sy, N)[source]
putflagsat(sexfile, sexfile2, regfile)[source]

Put flags on objects which are inside saturated regions

clusex.lib.sky module

class clusex.lib.sky.SkyCal[source]

Bases: object

This class compute the sky using two methods: random boxes and sky gradient

CorSize(xell, yell)[source]

Correct size for image borders

GetEllipSky(ImageFile, MaskFile, xx, yy, thetadeg, q, Rinit, width, namering, ringmask, outliers=False)[source]

Gradient sky method

GetRandBoxSky(Rinit, Rmax)[source]

compute mean, std, and median from random selected boxes

GetRandBoxSky2(Rinit, Rmax)[source]

compute mean, std, and median from random selected boxes

GetRandomCoord(coordinates)[source]

choose xinit, and yinit from coordinates

GetRandomPatch(imagemat, mimg, box, coordinates)[source]

get a random box patch of the imagemat

GetRingMask(masksky, idx)[source]

obtains the ring selected by index idx

GetSize(x, y, R, theta, q, ncol, nrow)[source]

this subroutine get the maximun and minimim pixels for Kron and sky ellipse

GetXYRBorder()[source]

this subroutine get the coordinates of the border

MakeCoord(xmino, xmaxo, ymino, ymaxo, xmaxf, ymaxf)[source]

creates (x,y) coordinates between the inner and outer box

MakeKron(imagemat, idn, x, y, R, theta, q, xmin, xmax, ymin, ymax)[source]

This subroutine create a Kron ellipse within a box defined by: xmin, xmax, ymin, ymax

RandBox(ImageFile, MaskFile, xx, yy, thetadeg, q, Rinit, box, num, Rmax, outliers=False)[source]

random box method to compute sky

clusex.lib.writesex module

clusex.lib.writesex.runsex(params)[source]
clusex.lib.writesex.wsex(params)[source]

Module contents