mirror of
https://github.com/cosinekitty/astronomy.git
synced 2025-12-23 23:58:15 -05:00
The BaryState function did not support Pluto before. Refactored the code so that the internal CalcPluto function returns both the position and velocity, and its caller can select from heliocentric or barycentric coordinates. HelioVector asks for heliocentric coordinates and keeps only the position vector. BaryState asks for barycentric coordinates and returns both position and velocity. I added test data for Pluto generated by JPL Horizons. It turns out the Pluto system barycenter is the best fit for TOP2013, presumably because Charon causes Pluto to wobble quite a bit. I also generated JPL Horizons test data for the Moon and the Earth/Moon barycenter, anticipating that I will support calculating their barycentric state vectors soon. I had to increase the enforced size limit for minified JavaScript from 100000 bytes to 120000 bytes. I guess this is like raising the "debt ceiling". Fixed a bug in Python unit tests: if "-v" verbose option was specified, it was printing a summary line for every single line of input, instead of a single summary after processing the whole file, as was intended. This is one of those Python whitespace indentation bugs!
35 lines
1.1 KiB
Python
Executable File
35 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import sys
|
|
import os
|
|
import re
|
|
|
|
def PatchReadme(readmeFileName, jsFileName):
|
|
nbytes = os.stat(jsFileName).st_size
|
|
if nbytes >= 120000:
|
|
print('ERROR(patch_readme.py): The size of {} has grown to {} bytes. This is too large!'.format(jsFileName, nbytes))
|
|
return 1
|
|
|
|
with open(readmeFileName, 'rt') as infile:
|
|
text = infile.read()
|
|
|
|
marker = '<!--MINIFIED_SIZE-->'
|
|
pattern = marker + '[0-9]*'
|
|
repl = marker + str(nbytes)
|
|
updated = re.sub(pattern, repl, text)
|
|
if updated != text:
|
|
with open(readmeFileName, 'wt') as outfile:
|
|
outfile.write(updated)
|
|
print('patch_readme.py: Updated {} with js size reported as {} bytes.'.format(readmeFileName, nbytes))
|
|
else:
|
|
print('patch_readme.py: No changes needed in {}.'.format(readmeFileName))
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if len(sys.argv) != 3:
|
|
print('USAGE: patch_readme.py readme_file js_file')
|
|
sys.exit(1)
|
|
readmeFileName = sys.argv[1]
|
|
jsFileName = sys.argv[2]
|
|
sys.exit(PatchReadme(readmeFileName, jsFileName))
|