Skip to content
Snippets Groups Projects
Commit fca08d0a authored by Ross Gray VIP - Physics's avatar Ross Gray VIP - Physics
Browse files

Adding the Gspec notebook

parent a91b21d4
No related branches found
No related tags found
No related merge requests found
GSpec.py 0 → 100644
'''
------------------------------------------
Title: GSPEC
Creation Date: 16/02/2024
Author: R. Gray
Version: v1
%%%%% CODE DESCRIPTION [BEGINS]
Class to wrap up some of the basic analysis of the Gspec
%%%%% CODE DESCRIPTION [ENDS]
------------------------------------------
'''
from PIL import Image
import numpy as np
import pandas as pd
class GSpec:
def __init__(self, filename, maskfile=None):
self.filename = filename
self.maskfile = maskfile
def loadfile(self):
im = Image.open(self.filename)
return im
def get_mask(self,im):
# Load the CSV file
df = pd.read_csv(self.maskfile)
# Assuming the last row contains the rotation angle applied to all points
rotation_angle = df.iloc[-1]['Rotation_Angle']
# Apply the rotation angle to the image
rotated_img = im.rotate(rotation_angle, expand=True)
rotated_img = np.asarray(rotated_img)
# Extract the coordinates from the DataFrame
coordinates = df[['X', 'Y']].to_numpy() # Exclude the last row used for angle
background_coords = np.copy(coordinates)
background_coords[:,1] = background_coords[:,1]-350
return rotated_img, coordinates, background_coords
\ No newline at end of file
Source diff could not be displayed: it is too large. Options to address this: view the blob.
# GSpec Analysis
This notebook gives some example of doing the basic analysis on the Gspec. It also makes use of the GSpec.py analysis class which is included in this repository.
# GSpec Image Mask Definition # GSpec Image Mask Definition
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment