import matplotlib # Force matplotlib to not use any Xwindows backend. matplotlib.use('Agg') from matplotlib import cm import math as m import numpy as np import scipy import pylab as pl import os import sys import time import pwd import glob from sklearn import neural_network as neunet #print(matplotlib.pyplot.colormaps()) #quit() deg = np.pi/180.0 fbas = "" mode = "" opts = "" if len(sys.argv)>=3: fbas = sys.argv[1] mode = sys.argv[2] if len(sys.argv)>=4: opts = sys.argv[3] else: print(' usage: '+sys.argv[0]+' FILE_BASE MODE [ OPTS ]\n') print(' FILE_BASE text data \n') print(' MODE can be tricky. \n') print(' OPTS plotquery ... (see code) \n') quit() fids = [] fnoids = [] if True: for fil in glob.glob(fbas+'*objlis.txt'): if '+id_' in fil: fids.append(fil) else: fnoids.append(fil) print('# files w/id, no id:',len(fids),len(fnoids)) ns = len(fids)+len(fnoids) nx = 20 ny = 20 data = np.zeros((ns,nx*ny)) labels = np.zeros(ns) names = np.zeros(ns,dtype=object) def lablabs(s): # if s=='gax': return 4 # elif s=='glcl': return 2 # elif s=='opcl': return 1 if s=='gax': return 1 elif s=='glcl': return 1 elif s=='opcl': return 1 return 0; gaxtypes = 'Galaxy LINER Radio LSB_G EmG GiC GinPair StarburstG AGN' starcltypes = 'GlCl OpCl' def datatoimg(brthis,gmagthis,x,y): H, xedges, yedges = np.histogram2d(brthis,gmagthis,bins=(x, y)) H = H.T; H = H.flatten() return H,xedges,yedges def gentrain(BRBR,GG,nt,x,y): # this generates a set of random draws from gmag, br = GG, BRBR # also, shifting gmag as if at a different distance nx = len(x)-1; ny = len(y)-1 dtarg = np.zeros((nt,nx*ny)) for i in range(nt): dgmag = 1*np.random.uniform()-0.5 gmagthis = np.copy(GG)+dgmag msk = gmagthis<21.0 gmagthis = gmagthis[msk] brthis = BRBR[msk] if len(brthis)>20: frac = ((0.9*np.random.uniform()+0.1)*len(brthis)) msk = np.random.uniform(0,1,len(brthis))