{"id":22215147,"url":"https://github.com/iancze/tresmerge","last_synced_at":"2025-03-25T06:41:21.709Z","repository":{"id":141893890,"uuid":"147558192","full_name":"iancze/tresmerge","owner":"iancze","description":"Pseudo-flux calibrate and merge TRES echelle spectra","archived":false,"fork":false,"pushed_at":"2018-09-10T03:39:38.000Z","size":1564,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T06:11:29.830Z","etag":null,"topics":["astronomy","calibration","echelle","radial","spectra","spectrograph","tres","velocity"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iancze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-09-05T17:53:45.000Z","updated_at":"2018-09-10T03:39:39.000Z","dependencies_parsed_at":"2023-03-13T10:27:58.867Z","dependency_job_id":null,"html_url":"https://github.com/iancze/tresmerge","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"bc71e1a95b3c8088705c6339c6520bf8d87caba4"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iancze%2Ftresmerge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iancze%2Ftresmerge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iancze%2Ftresmerge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iancze%2Ftresmerge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iancze","download_url":"https://codeload.github.com/iancze/tresmerge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245414524,"owners_count":20611364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astronomy","calibration","echelle","radial","spectra","spectrograph","tres","velocity"],"created_at":"2024-12-02T21:26:18.110Z","updated_at":"2025-03-25T06:41:21.693Z","avatar_url":"https://github.com/iancze.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tresmerge\nPseudo-flux calibrate and merge TRES echelle spectra\n\n## Citations\n\nIf you make use of this code, please cite this repository as\n\n    @misc{tresmerge_czekala,\n      author       = {Ian Czekala},\n      title        = {iancze/tresmerge: beta},\n      month        = sep,\n      year         = 2018,\n      doi          = {10.5281/zenodo.1411998},\n      url          = {https://doi.org/10.5281/zenodo.1411998}\n    }\n\n\n![Sample](sample.png)\n\nThis package requires Python 3 and the following packages:\n\n* numpy\n* scipy\n* matplotlib\n* astropy\n* astropy/specutils: https://github.com/astropy/specutils\n\nYou can try installing these individually yourself beforehand, or the installation process should be able to install them all for you.\n\n## Installation\n\nDownload this package, `cd` to the directory, and run\n\n    $python setup.py install\n\nor\n\n    $python3 setup.py install\n\nIf you're on a system without administrative priveledges, you might need to add the `--user` flag to the above command. Also, take a look at the commands that are printed out after the install command, since you may need to add the scripts directory to your system PATH. In my case, I needed to add the `/home/iczekala/.local/bin` directory to my `.cshrc` file.\n\nMake sure that `python` or `python3` points to the Python 3 version you want to use. You can check that this is the correct version by first entering the Python interpreter, and you should see something like\n\n    $ python\n    Python 3.6.3 |Anaconda custom (64-bit)| (default, Nov  3 2017, 19:19:16)\n    [GCC 7.2.0] on linux\n    Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n    \u003e\u003e\u003e\n\nThese scripts have not been tested with Python 2.x and will likely not work. It's recommended you upgrade to Python 3.\n\nThe main script that you should use to run everything is called `tresmerge-process`, e.g.,\n\n    $ tresmerge-process --help\n    usage: tresmerge-process [-h] [--outfile OUTFILE] [--clobber] [--plot]\n                         [-t TRIM] [--shift SHIFT] [--poly-order POLY_ORDER]\n                         rfits bfits template\n\n    Merge TRES echelle orders.\n\n    positional arguments:\n      rfits                 Name of the FITS file containing the RAW spectrum to\n                            merge.\n      bfits                 Name of the FITS file containing the BLAZE-corrected\n                            spectrum to merge.\n      template              Name of the FITS file containing the Kurucz template\n                            spectrum.\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      --outfile OUTFILE     Name of the output file to write the merged echelle\n                            spectrum to.\n      --clobber             Overwrite any existing output file with new data.\n      --plot                Make a set of plots of the merged spectra.\n      -t TRIM, --trim TRIM  How many pixels to trim from the front of the file.\n                            Default is 6\n      --shift SHIFT         Doppler shift the synthetic spectrum by this amount\n                            (in km/s) before doing the merge process. This may\n                            help if the target star has an exceptionally high\n                            radial velocity. Positive velocities correspond to\n                            redshifting the template.\n      --poly-order POLY_ORDER\n                            The order Chebyshev polynomial used to flatten each\n                            echelle order. 0 = constant, 1 = line, 2 = parabola, 3\n                            = cubic, ... etc.\n\n## Updating your package\n\nIf you've previously installed this package, and there's been a new update, here is how you can proceed. If you used `git` to download this package, first `cd` to the repository and run\n\n    $ git pull\n\nThis command will use git to bring down all of the new changes. Then, run\n\n    $python setup.py install\n\nagain to install these changes to your system. If you didn't use `git` to download the package in the first place, you can delete the repository, download a new `.zip` package, and install it as before.\n\n\n## How this package works\n\nThis purpose of this code is to merge overlapping echelle orders of TRES spectrograph data into a single spectrum. Where there is no data in the redder echelle gaps, the code leaves no-data (despite what may appear as plotting artifacts).\n\nThe data in each echelle order is compared to a synthetic template spectrum that the user provides. The mismatch is accounted for by fitting an `n`-th order (user specifies `n`) polynomial to the data and flattening it until it matches the template.\n\nThe output is written to an enhanced-CSV file, which can be read by `astropy.io.ascii`, or any CSV reader. The header values in the original FITS files are copied as comments.\n\n### Usage\n\nFor example, if you had two directories each containing the raw and blaze-corrected spectra, and a template, then you would run the code like this\n\n    $ tresmerge-process raw/hii468_2017-11-23_04h35m56s_cb.spec.fits blaze/hii468_2017-11-23_04h35m56s_cb.spec.fits t12000g40p00v180s.fits --plot\n\nIf you enabled plotting (via `--plot`), then you should see an `output.pdf` with the spectra. You should also see an outfile containing the merged spectrum as a text file.\n\n## Notes about quality of merging\n\nFor orders with deep absorption lines, the quality of fit of the synthetic spectra to the data makes a difference. Because the polynomial-fitting process seeks to minimize the distance between the synthetic spectra and data for each order, if the template has a number of inaccurate lines, then the polynomial fit will be biased. Future plans for this package may include adding in a masking option to do the polynomial fitting while excluding user-specified regions of the template, so please contact me or raise an issue on this repo if such a feature extension would be helpful.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiancze%2Ftresmerge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiancze%2Ftresmerge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiancze%2Ftresmerge/lists"}