def nominal_to_altaz(nominal, horizon_center=(0, 0)): """Transform nominal coordinates to horizon coordinates. nominal = (x, y) in meter horizon_center = (az_center, alt_center) in deg Returns: horizon = (az, alt) in deg """ x, y = np.asarray(nominal, dtype='float64') az_center, alt_center = np.asarray(horizon_center, dtype='float64') header = {'NAXIS': 2, 'NAXIS1': 100, 'NAXIS2': 100, 'CTYPE1': 'RA---TAN', 'CRVAL1': az_center, 'CRPIX1': 0, 'CUNIT1': 'deg', 'CDELT1': np.degrees(1), 'CTYPE2': 'DEC--TAN', 'CRVAL2': alt_center, 'CRPIX2': 0, 'CUNIT2': 'deg', 'CDELT2': np.degrees(1), } projection = Projection(header) altaz = projection.toworld((y, x)) return altaz[0], altaz[1]
def nominal_to_altaz(nominal, horizon_center=(0, 0)): """Transform nominal coordinates to horizon coordinates. nominal = (x, y) in meter horizon_center = (az_center, alt_center) in deg Returns: horizon = (az, alt) in deg """ x, y = np.asarray(nominal, dtype='float64') az_center, alt_center = np.asarray(horizon_center, dtype='float64') header = {'NAXIS': 2, 'NAXIS1': 100, 'NAXIS2': 100, 'CTYPE1': 'RA---TAN', 'CRVAL1': az_center, 'CRPIX1': 0, 'CUNIT1': 'deg', 'CDELT1': np.degrees(1), 'CTYPE2': 'DEC--TAN', 'CRVAL2': alt_center, 'CRPIX2': 0, 'CUNIT2': 'deg', 'CDELT2': np.degrees(1), } projection = Projection(header) altaz = projection.toworld((y, x)) return altaz[0], altaz[1]
def add_tan_world_coordinates(csv_file, outfile): """Compute alt, az from x, y nominal coordinates and add as columns to a CSV file.""" from kapteyn.wcs import Projection logging.info('Reading file: {0}'.format(csv_file)) data = np.recfromcsv(csv_file) camX = data['cameraxevent'] camY = data['camerayevent'] alts = data['altsystem'] azs = data['azsystem'] infile = open(csv_file) logging.info('Writing file: {0}'.format(outfile)) outfile = open(outfile, 'w') names = infile.readline().split() names.append(',GnomAz,GnomAlt\n') line = ' '.join(names) line = line.replace(' ', '') outfile.write(line) for ii in np.arange(0, len(alts) - 1, 1): header = { 'NAXIS': 2, 'NAXIS1': 100, 'NAXIS2': 100, 'CTYPE1': 'RA---TAN', 'CRVAL1': azs[ii], 'CRPIX1': 0, 'CUNIT1': 'deg', 'CDELT1': np.degrees(1), 'CTYPE2': 'DEC--TAN', 'CRVAL2': alts[ii], 'CRPIX2': 0, 'CUNIT2': 'deg', 'CDELT2': np.degrees(1), } projection = Projection(header) gnoms = projection.toworld((camY[ii], camX[ii])) values = infile.readline().split() values.append(',%s,%s\n' % (str(gnoms[0]), str(gnoms[1]))) line = ' '.join(values) line = line.replace(' ', '') outfile.write(line) infile.close() outfile.close()
def add_tan_world_coordinates(csv_file, outfile): """Compute alt, az from x, y nominal coordinates and add as columns to a CSV file.""" from kapteyn.wcs import Projection logging.info('Reading file: {0}'.format(csv_file)) data = np.recfromcsv(csv_file) camX = data['cameraxevent'] camY = data['camerayevent'] alts = data['altsystem'] azs = data['azsystem'] infile = file(csv_file) logging.info('Writing file: {0}'.format(outfile)) outfile = file(outfile, 'w') names = infile.readline().split() names.append(',GnomAz,GnomAlt\n') line = ' '.join(names) line = line.replace(' ', '') outfile.write(line) for ii in np.arange(0, len(alts) - 1, 1): header = {'NAXIS': 2, 'NAXIS1': 100, 'NAXIS2': 100, 'CTYPE1': 'RA---TAN', 'CRVAL1': azs[ii], 'CRPIX1': 0, 'CUNIT1': 'deg', 'CDELT1': np.degrees(1), 'CTYPE2': 'DEC--TAN', 'CRVAL2': alts[ii], 'CRPIX2': 0, 'CUNIT2': 'deg', 'CDELT2': np.degrees(1), } projection = Projection(header) gnoms = projection.toworld((camY[ii], camX[ii])) values = infile.readline().split() values.append(',%s,%s\n' % (str(gnoms[0]), str(gnoms[1]))) line = ' '.join(values) line = line.replace(' ', '') outfile.write(line) infile.close() outfile.close()