Skip to content

Commit

Permalink
requirements and setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jurjen93 committed May 17, 2021
1 parent a2de183 commit 0d4af58
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 15 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -27,30 +31,30 @@ 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.
* ```-fr``` -> Frame rate of the video. Advice is to use ```20``` to make the video smooth but doesn't take too long to record.
* ```-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.
Expand All @@ -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*\
Expand Down
6 changes: 5 additions & 1 deletion make_movie.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 11 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions video/scripts/moviemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand All @@ -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__':
Expand Down

0 comments on commit 0d4af58

Please sign in to comment.