Skip to content

Instantly share code, notes, and snippets.

@dsberry
Created March 28, 2016 08:42
Show Gist options
  • Save dsberry/9a0dc13c86e8db9f4df1 to your computer and use it in GitHub Desktop.
Save dsberry/9a0dc13c86e8db9f4df1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import starlink.Ast as Ast
# Create a text file containing an STC-S phrase.
with open("stcs1","w") as f:
f.write('''
Union ICRS TOPOCENTER (
Circle 180 10 20
Circle 190 10 20
Intersection (
Circle 120 -10 20
Difference (
Circle 130 -10 20
Circle 125 -10 2
)
Not ( Circle 118 -8 3 )
)
Box 165 -30 30 60
)
''')
# Create a text file containing a second STC-S phrase.
with open("stcs2","w") as f:
f.write('''
Circle ICRS TOPOCENTER 150 0 5
''')
# Create an StcsChan - a channel for converting between STC-S phraes and
# AST Objects.
ch = Ast.StcsChan()
ch.ReportLevel = 3
# Read the first STC-S phrase, creating an AST Region.
ch.SourceFile = "stcs1"
obj1 = ch.read()
# Read the second STC-S phrase, creating another AST Region.
ch.SourceFile = "stcs2"
obj2 = ch.read()
# Test if the two Regions overlap.
if obj2.overlap(obj1):
print( "They overlap" )
else:
print( "They do not overlap" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment