Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fft / inverse fft #12

Merged
merged 19 commits into from
Nov 4, 2024
Merged

fft / inverse fft #12

merged 19 commits into from
Nov 4, 2024

Conversation

zbpetersbuf
Copy link
Contributor

@zbpetersbuf zbpetersbuf commented Nov 2, 2024

Contents

  • One module containing the function to create the graph of the inverse fft
  • Another selecting the main frequencies for you?
  • some form of test function and read me

Reviewer

  • reviewer who has seen or understands fit and fft^-1

@zbpetersbuf zbpetersbuf added the python python related label Nov 2, 2024
@zbpetersbuf zbpetersbuf self-assigned this Nov 2, 2024
@zbpetersbuf zbpetersbuf added this to the fft / inverse fft milestone Nov 2, 2024
@laserlab
Copy link
Contributor

laserlab commented Nov 2, 2024

@ubsuny/cp1-24 Anyone interested to review this?

@laserlab
Copy link
Contributor

laserlab commented Nov 2, 2024

@zbpetersbuf please use the file names as requested in the homework description!

@laserlab laserlab linked an issue Nov 2, 2024 that may be closed by this pull request
@zbpetersbuf
Copy link
Contributor Author

so I will be sure to do the following (rename the module preparation.py, and gives the freq in the useful values) only,

  1. I am unsure how these css files will be made so I can't finish this code yet but I do have a placeholder that I can easily change
  2. I committed my newest changes from the codespace to show what I was working on

@zbpetersbuf
Copy link
Contributor Author

also I am unsure what this pycache file is, I thought I didn't push this but it appeared regardless, should I delete this?

@laserlab
Copy link
Contributor

laserlab commented Nov 2, 2024

@zbpetersbuf so your PR should only contain 2 files:

  1. preparation.py
  2. test_preparation.py

@laserlab laserlab self-requested a review November 2, 2024 21:54
@laserlab
Copy link
Contributor

laserlab commented Nov 2, 2024

@ubsuny/cp1-24 Anyone interested to review this?

I will review this PR

Copy link
Contributor

@laserlab laserlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • remove files
  • change file name
  • check functions
  • add docstrings
  • add unit test

import math as m
import numpy as np

def analyze_signal(signal, fs, use_filter, selec_filter):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please call this something like “fft”
also make sure this actually takes a pandas time series. in the moment you assume some fs as a time step. That is not how a pandas time series or the CO2 data is organized. Also you do not need any filters since this is another task

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im aware of this but since I dont know what that data will look like this is a placeholder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also fft is already a function in numpy so I though I wasn't just making those functions, but I can if that's what's being asked of me this is no problem I just need to know

the modles in the function include liner polynomial cubic and exponential
"""

def anze_revm_trnd(signal, fs, use_filter, selec_filter):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not part of your homework task. You can leave it but it has to work with the pandas time series

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I am not removing the overall trend to this data before finding the inv fft?

fft_folder/readme_tobedeleted.md Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a unit test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just something for myself I am not finished with my task

fft_folder/__pycache__/inv_fft.cpython-312.pyc Outdated Show resolved Hide resolved
fft_folder/__pycache__/plots_ifft.cpython-312.pyc Outdated Show resolved Hide resolved
"""
inv_fft.py
inverse fast fourie transform
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be renamed to preparation.pycans should container at least three functions:

  1. fft
  2. inverse fft
  3. calculate frequencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the task was to make my own fft function? and not use the numpy functions?

@zbpetersbuf
Copy link
Contributor Author

ok to be clear I am not done with this I apologize for the inconvenience

@laserlab
Copy link
Contributor

laserlab commented Nov 3, 2024

ok to be clear I am not done with this I apologize for the inconvenience

I know. I just wanted you to point you in the right direction.

@zbpetersbuf
Copy link
Contributor Author

So the task was to make my own fft, ifft and a function that finds the frequencies? and not use the numpy functions?

@laserlab
Copy link
Contributor

laserlab commented Nov 3, 2024

So the task was to make my own fft, ifft and a function that finds the frequencies? and not use the numpy functions?

No, use numpy fft and inverse fft inside a function that can use the pandas time series data format

@laserlab
Copy link
Contributor

laserlab commented Nov 3, 2024

Please note my comment in #3 (comment) to what your function should take as data

Copy link
Contributor

@laserlab laserlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some changes but merging for now to have a starter for the next functions

return np.fft.ifft(matrx)

def calc_freq(data):
n = len(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works if your time unit is seconds for returning Hz


def inv_fft(data):

matrx = np.fft.fft(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don’t need to take the fft first your fft function does that

matrx = np.fft.fft(data)
return np.abs(matrx)

def inv_fft(data):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will have to take a frequency as input

"""
import numpy as np

def fft(data):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you rely on that data is the time data in equidistant time slots. This will fail e.g. for months which are not the same lengths.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a unit test function

@laserlab
Copy link
Contributor

laserlab commented Nov 4, 2024

@SchrodingersStruggle merging this for now to have a starter file

@laserlab laserlab merged commit 78839c8 into ubsuny:main Nov 4, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python python related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zbpetersbuf is doing fft / inverse fft
2 participants