From 0d4af58fcd2ab881494efaa1633d7e4d9caa4650 Mon Sep 17 00:00:00 2001 From: jurjen93 Date: Mon, 17 May 2021 10:19:36 +0200 Subject: [PATCH] requirements and setup --- README.md | 22 +++++++++++++--------- make_movie.py | 6 +++++- requirements.txt | 11 +++++++++++ setup.sh | 16 ++++++++++++++++ video/scripts/moviemaker.py | 10 +++++----- 5 files changed, 50 insertions(+), 15 deletions(-) mode change 100644 => 100755 make_movie.py create mode 100644 requirements.txt create mode 100644 setup.sh diff --git a/README.md b/README.md index 29ed6bf..c58171b 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,13 @@ Other .fits files from LOFAR can be found here: https://lofar-surveys.org/ ### Clone repo -You need to clone this repo with: +You need to clone this repo with:\ ```git clone https://github.com/jurjen93/advanced_astro_visualiziation.git``` +### Install requirements +Now you can install the requirements and make aliases to simplify commands with:\ +```./setup.sh``` + ### Catalogue csv file You need to have a catalogue with sources for the poster (for the video it is optional). We have an example given in the folder 'catalogue'.\ Use the following fields: @@ -27,18 +31,18 @@ First, download **Scribus**: https://sourceforge.net/projects/scribus/files/scribus-devel/1.5.5/scribus-1.5.5-windows-x64.exe/download Run now:\ -```python make_poster.py```\ +```makeposter```\ where you can use the following flags * ```-d``` -> Choose to download a specific fits file from the internet. Use ```1``` if you want to, leave empty otherwise. * ```-csv``` -> Give a specific csv file with sources to include as cutouts in the poster. * ```-fi``` -> Fits file to use. (If you don't download your fits file) Example:\ -```python make_poster.py -csv catalogue/catalogue_lockman.csv -fi fits/lockman_hole.fits``` +```makeposter -csv catalogue/catalogue_lockman.csv -fi fits/lockman_hole.fits``` ### How to make the video Run:\ -```python make_video.py```\ +```makevideo```\ where you can use the following flags * ```-d``` -> Choose to download a specific fits file from the internet. Use ```1``` if you want to, leave empty otherwise. * ```-csv``` -> Give a specific csv file with sources to include as cutouts in the poster. If you leave it empty, it goes through the whole field. @@ -46,11 +50,11 @@ where you can use the following flags * ```-fi``` -> Fits file to use. (If you don't download your fits file) Example pan through source by source from your csv file:\ -```python make_video.py -csv catalogue/catalogue_lockman.csv -d 1 -f 60```\ +```makevideo -csv catalogue/catalogue_lockman.csv -d 1 -f 60```\ Example of pan through a whole field:\ -```python make_video.py -fi fits/your_fits.fits```\ +```makevideo -fi fits/your_fits.fits```\ In the video one can see the coordinates. If you want to make a separate image from this, you can run the following:\ -```python make_image.py -fi fits/your_fits.fits -ra 123.123 -dec 51.123 -si 0.4```\ +```makeimage -fi fits/your_fits.fits -ra 123.123 -dec 51.123 -si 0.4```\ where you can use the following flags * ```-si``` -> Size in degrees. * ```-dec``` -> Declination in degrees. @@ -62,13 +66,13 @@ https://towardsdatascience.com/how-to-make-a-video-from-your-astronomy-images-95 ### How to make the interactive plot Run:\ -```python make_interactive.py```\ +```makeinteractive```\ where you can use the following flags * ```-d``` -> Choose to download a specific fits file from the internet. Use ```1``` if you want to, leave empty otherwise. * ```-fi``` -> Fits file to use. (If you don't download your fits file) Example:\ -```python make_interactive.py -fi fits/your_fits.fits``` +```makeinteractive -fi fits/your_fits.fits``` ### Output **Poster**: *poster.pdf*\ diff --git a/make_movie.py b/make_movie.py old mode 100644 new mode 100755 index e4fb577..9840b40 --- a/make_movie.py +++ b/make_movie.py @@ -38,7 +38,11 @@ def isNaN(a): file = args.fits else: file = 'fits/elias.fits' - Movie = MovieMaker(fits_file=get_pkg_data_filename(file), + try: + fitsfile=get_pkg_data_filename(file) + except: + fitsfile=file + Movie = MovieMaker(fits_file=fitsfile, imsize=0.4,#default imsize framerate=FRAMERATE, zoom_effect=False) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a5ad4af --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +numpy==1.18.1 +opencv-python==4.5.1.48 +termcolor==1.1.0 +matplotlib==3.1.3 +astropy==4.0 +scipy==1.4.1 +bdsf==1.9.2 +aplpy==2.0.3 +reproject==0.7.1 +pandas==1.0.1 +bokeh==1.4.0 \ No newline at end of file diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..e00c79f --- /dev/null +++ b/setup.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +#install requirements +pip install -r requirements.txt + +#make alias to run script easier +alias makevideo="python3 $PWD/make_movie.py" +alias makeimage="python3 $PWD/make_image.py" +alias makeposter="python3 $PWD/make_poster.py" +alias makeinteractive="python3 $PWD/make_interactive.py" + +#chmod everything +chmod u+x $PWD/make_movie.py +chmod u+x $PWD/make_image.py +chmod u+x $PWD/make_poster.py +chmod u+x $PWD/make_interactive.py \ No newline at end of file diff --git a/video/scripts/moviemaker.py b/video/scripts/moviemaker.py index a77cb22..6ae8e11 100644 --- a/video/scripts/moviemaker.py +++ b/video/scripts/moviemaker.py @@ -17,7 +17,7 @@ class MovieMaker(ImagingLofar): """ def __init__(self, fits_file: str = None, imsize: float = None, framerate: float = None, process: str = None, fits_download: bool=False, new: bool = True, text: str = None, vmin: float = None, vmax: float = None, zoom_effect: bool = False, - output_file: str = 'video/frames', cmap: str = None): + output_file: str = 'frames', cmap: str = None): """ :param fits_file: fits file name :param imsize: initial image size @@ -96,7 +96,7 @@ def make_frame(self, N, ra = None, dec = None, imsize: float = None, dpi: float def make_frames(self): """ - Record individual frames and save in video/frames/ + Record individual frames and save in frames/ ------------------------------------------------------------ """ self.N_max = len(os.listdir(self.output_file))+len(self.ragrid) #max number of videos @@ -223,7 +223,7 @@ def crop_center(img,cropx,cropy): return img[starty:starty+cropy,startx:startx+cropx,:] def fading_effect(source, frames): - images = glob('/home/jurjen/Documents/Python/advanced_astro_visualiziation/video/frames_high/*') + images = glob('/home/jurjen/Documents/Python/advanced_astro_visualiziation/frames_high/*') img1 = cv.imread(sorted(images)[-1]) img1 = cv.GaussianBlur(img1, (5,5), 0) img2 = cv.imread(glob(f'/home/jurjen/Documents/Python/advanced_astro_visualiziation/fits/highres_P205/{source}*MFS-image.png')[0]) @@ -244,8 +244,8 @@ def fading_effect(source, frames): if alpha==1: n=frames//6 for r in range(n): - images = glob('/home/jurjen/Documents/Python/advanced_astro_visualiziation/video/frames_high/*') - new_im_name = f'/home/jurjen/Documents/Python/advanced_astro_visualiziation/video/frames_high/image_{str(len(images)).rjust(5, "0")}.png' + images = glob('/home/jurjen/Documents/Python/advanced_astro_visualiziation/frames_high/*') + new_im_name = f'/home/jurjen/Documents/Python/advanced_astro_visualiziation/frames_high/image_{str(len(images)).rjust(5, "0")}.png' cv.imwrite(new_im_name, output) if __name__ == '__main__':