-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed test_conda_pyimfit.py to test_pyimfit_install.py, made it mor…
…e general script that downloads example directory if it is not found locally.
- Loading branch information
Showing
6 changed files
with
85 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Simple test script to see if we can a) import pymfit; and b) run a simple fit | ||
# using it. Uses files in the default Imfit examples/ directory (downloads and | ||
# unpacks this if it isn't in the lcoal directory). | ||
|
||
import sys, os, tarfile | ||
import requests | ||
import pyimfit | ||
from astropy.io import fits | ||
|
||
|
||
# UPDATE THIS TO POING TO WHERE THE IMFIT-EXAMPLES DIRECTORY IS LOCATED | ||
BASE_DIR_ERWIN = "/Users/erwin/coding/imfit/examples/bob/" | ||
EXAMPLES_URL = "https://www.mpe.mpg.de/~erwin/resources/imfit/imfit_examples.tar.gz" | ||
|
||
IMAGE_FILE = "ic3478rss_256.fits" | ||
CONFGI_FILE = "config_sersic_ic3478_256.dat" | ||
|
||
|
||
|
||
def main( argv ): | ||
# By default, we look for a pre-existing Imfit examples/ subdirectory in the current directory | ||
# If not found, we look in BASE_DIR_ERWIN; if not found there, we download and unpack it | ||
# from the Imfit webpage at MPE | ||
if os.path.exists("./examples"): | ||
baseDir = "./examples/" | ||
elif os.path.exists(BASE_DIR_ERWIN): | ||
baseDir = BASE_DIR_ERWIN | ||
else: | ||
print("ERROR: Unable to locate pre-existing examples directory.") | ||
print("Downloading and unpacking examples directory...") | ||
r = requests.get(EXAMPLES_URL, allow_redirects=True) | ||
open('examples.tar.gz', 'wb').write(r.content) | ||
tar = tarfile.open("examples.tar.gz") | ||
tar.extractall(filter='data') | ||
tar.close() | ||
baseDir = "./examples/" | ||
print("Done.") | ||
|
||
imageFile = baseDir + IMAGE_FILE | ||
configFile = baseDir + CONFGI_FILE | ||
|
||
print("\nStarting test...") | ||
vinfo = sys.version_info | ||
print("Python version {0}.{1}".format(vinfo[0], vinfo[1])) | ||
print("PyImfit version {0}".format(pyimfit.__version__)) | ||
|
||
filesExist = True | ||
if not os.path.exists(imageFile): | ||
print("ERROR: Unable to locate image file (path = %s" % imageFile) | ||
filesExist = False | ||
if not os.path.exists(configFile): | ||
print("ERROR: Unable to locate Imfit config file (path = %s" % configFile) | ||
filesExist = False | ||
|
||
if filesExist: | ||
image_data = fits.getdata(imageFile) | ||
model_desc = pyimfit.ModelDescription.load(configFile) | ||
imfit_fitter = pyimfit.Imfit(model_desc) | ||
print("Doing the fit...") | ||
fit_result = imfit_fitter.fit(image_data, gain=4.725, read_noise=4.3, original_sky=130.14) | ||
print(fit_result) | ||
print("Done!\n") | ||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule imfit
updated
13 files
+1 −20 | CHANGELOG.md | |
+3 −1 | SConstruct | |
+7 −8 | core/add_functions.cpp | |
+1 −19 | core/config_file_parser.cpp | |
+ − | docs/imfit_howto.pdf | |
+14 −73 | docs/imfit_howto.tex | |
+0 −253 | function_objects/func_peanut_dattathri.cpp | |
+0 −44 | function_objects/func_peanut_dattathri.h | |
+2 −2 | function_objects/integrator.cpp | |
+1 −1 | run_unittest_add_functions.sh | |
+0 −1 | run_unittest_model_object.sh | |
+0 −1 | tests/makeimage_reference/makeimage_textout0 | |
+0 −1 | unit_tests/unittest_add_functions.t.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters