示例#1
0
def add_virtual_columns_celestial(self, long_in, lat_in, long_out, lat_out, input=None, output=None, name_prefix="__celestial", radians=False):
    import kapteyn.celestial as c
    input = input if input is not None else c.equatorial
    output = output if output is not None else c.galactic
    matrix = c.skymatrix((input, 'j2000', c.fk5), output)[0].tolist()
    if not radians:
        long_in = "pi/180.*%s" % long_in
        lat_in = "pi/180.*%s" % lat_in
    x_in = name_prefix + "_in_x"
    y_in = name_prefix + "_in_y"
    z_in = name_prefix + "_in_z"
    x_out = name_prefix + "_out_x"
    y_out = name_prefix + "_out_y"
    z_out = name_prefix + "_out_z"
    self.add_virtual_column(x_in, "cos({long_in})*cos({lat_in})".format(**locals()))
    self.add_virtual_column(y_in, "sin({long_in})*cos({lat_in})".format(**locals()))
    self.add_virtual_column(z_in, "sin({lat_in})".format(**locals()))
    self.add_virtual_columns_matrix3d(x_in, y_in, z_in, x_out, y_out, z_out,
                                      matrix, name_prefix + "_matrix")
    transform = "" if radians else "*180./pi"
    x = x_out
    y = y_out
    z = z_out
    self.add_virtual_column(long_out, "arctan2({y}, {x}){transform}".format(**locals()))
    self.add_virtual_column(lat_out, "(-arccos({z}/sqrt({x}**2+{y}**2+{z}**2))+pi/2){transform}".format(**locals()))
示例#2
0
def add_virtual_columns_celestial(self,
                                  long_in,
                                  lat_in,
                                  long_out,
                                  lat_out,
                                  input=None,
                                  output=None,
                                  name_prefix="__celestial",
                                  radians=False):
    import kapteyn.celestial as c
    input = input if input is not None else c.equatorial
    output = output if output is not None else c.galactic
    matrix = c.skymatrix((input, 'j2000', c.fk5), output)[0]
    if not radians:
        long_in = "pi/180.*%s" % long_in
        lat_in = "pi/180.*%s" % lat_in
    x_in = name_prefix + "_in_x"
    y_in = name_prefix + "_in_y"
    z_in = name_prefix + "_in_z"
    x_out = name_prefix + "_out_x"
    y_out = name_prefix + "_out_y"
    z_out = name_prefix + "_out_z"
    self.add_virtual_column(x_in,
                            "cos({long_in})*cos({lat_in})".format(**locals()))
    self.add_virtual_column(y_in,
                            "sin({long_in})*cos({lat_in})".format(**locals()))
    self.add_virtual_column(z_in, "sin({lat_in})".format(**locals()))
    # self.add_virtual_columns_spherical_to_cartesian(long_in, lat_in, None, x_in, y_in, z_in, cov_matrix_alpha_delta=)
    self.add_virtual_columns_matrix3d(x_in, y_in, z_in, x_out, y_out, z_out,
                                      matrix, name_prefix + "_matrix")
    # long_out_expr = "arctan2({y_out},{x_out})".format(**locals())
    # lat_out_expr = "arctan2({z_out},sqrt({x_out}**2+{y_out}**2))".format(**locals())
    # if not radians:
    #   long_out_expr = "180./pi*%s" % long_out_expr
    #   lat_out_expr = "180./pi*%s" % lat_out_expr
    transform = "" if radians else "*180./pi"
    x = x_out
    y = y_out
    z = z_out
    # self.add_virtual_column(long_out, "((arctan2({y}, {x})+2*pi) % (2*pi)){transform}".format(**locals()))
    self.add_virtual_column(long_out,
                            "arctan2({y}, {x}){transform}".format(**locals()))
    self.add_virtual_column(
        lat_out,
        "(-arccos({z}/sqrt({x}**2+{y}**2+{z}**2))+pi/2){transform}".format(
            **locals()))
示例#3
0
			raise common.STCSParseError("Invalid STCS (%s)"%str(msg))

	return parse


parseSimpleSTCS = getSimpleSTCSParser()


def simpleSTCSToPolygon(stcsExpr):
	"""returns an spoly for an STC-S region specification.

	This is used to let people upload VOTables with REGION items.
	"""
	if stcsExpr is None:
		return None
	return parseSimpleSTCS(stcsExpr).asPoly()


if __name__=="__main__":
# compute the Euler angles given above.  pgsphere has its rotation
# matrices opposite to ours (ccw rather than cw), hence the negation
	from kapteyn import celestial
	from gavo.stc import sphermath
	print "FK4:", tuple(-a for a in 
		sphermath.getEulerAnglesFromMatrix(
			celestial.skymatrix("icrs", "fk4 B1950.0")[0]))
	print "GAL:", tuple(-a for a in 
		sphermath.getEulerAnglesFromMatrix(
			celestial.skymatrix("icrs", "galactic")[0]))