<commit_before># Set the WCS information manually by setting properties of the WCS
# object.

from __future__ import division # confidence high

import numpy
from astropy import wcs
import pyfits
import sys

# Create a new WCS object.  The number of axes must be set
# from the start
w = wcs.WCS(naxis=2)

# Set up an "Airy's zenithal" projection
# Vector properties may be set with Python lists, or Numpy arrays
w.wcs.crpix = [-234.75, 8.3393]
w.wcs.cdelt = numpy.array([-0.066667, 0.066667])
w.wcs.crval = [0, -90]
w.wcs.ctype = ["RA---AIR", "DEC--AIR"]
w.wcs.set_pv([(2, 1, 45.0)])

# Print out the "name" of the WCS, as defined in the FITS header
print w.wcs.name

w.wcs.print_contents()

# Some pixel coordinates of interest.
pixcrd = numpy.array([[0,0],[24,38],[45,98]], numpy.float_)

# Convert pixel coordinates to world coordinates
world = w.wcs_pix2sky(pixcrd, 1)
print world

# Convert the same coordinates back to pixel coordinates.
pixcrd2 = w.wcs_sky2pix(world, 1)
print pixcrd2

# These should be the same as the original pixel coordinates, modulo
# some floating-point error.
assert numpy.max(numpy.abs(pixcrd - pixcrd2)) < 1e-6

# Now, write out the WCS object as a FITS header
header = w.to_header()

# header is a PyFITS Header object.  We can use it to create a new<commit_msg>Update the "generating a WCS object programmatically" example so it doesn't do anything boring and meaningless ;)  Addresses part of #83.<commit_after># Set the WCS information manually by setting properties of the WCS
# object.

from __future__ import division # confidence high

import numpy
from astropy import wcs
import pyfits
import sys

# Create a new WCS object.  The number of axes must be set
# from the start
w = wcs.WCS(naxis=2)

# Set up an "Airy's zenithal" projection
# Vector properties may be set with Python lists, or Numpy arrays
w.wcs.crpix = [-234.75, 8.3393]
w.wcs.cdelt = numpy.array([-0.066667, 0.066667])
w.wcs.crval = [0, -90]
w.wcs.ctype = ["RA---AIR", "DEC--AIR"]
w.wcs.set_pv([(2, 1, 45.0)])

# Print out all of the contents of the WCS object
w.wcs.print_contents()

# Some pixel coordinates of interest.
pixcrd = numpy.array([[0,0],[24,38],[45,98]], numpy.float_)

# Convert pixel coordinates to world coordinates
world = w.wcs_pix2sky(pixcrd, 1)
print world

# Convert the same coordinates back to pixel coordinates.
pixcrd2 = w.wcs_sky2pix(world, 1)
print pixcrd2

# These should be the same as the original pixel coordinates, modulo
# some floating-point error.
assert numpy.max(numpy.abs(pixcrd - pixcrd2)) < 1e-6

# Now, write out the WCS object as a FITS header
header = w.to_header()

# header is a PyFITS Header object.  We can use it to create a new
{'fraction_non_alphanumeric': 0.10577281191806331, 'fraction_numerical': 0.03947858472998138, 'mean_word_length': 4.155470249520153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3931365', 'n_tokens_mistral': 1003, 'n_tokens_neox': 931, 'n_words': 353}