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

problems installing requirements.txt #3

Open
leomiquelutti opened this issue Dec 5, 2024 · 2 comments
Open

problems installing requirements.txt #3

leomiquelutti opened this issue Dec 5, 2024 · 2 comments

Comments

@leomiquelutti
Copy link

Hi there,

I want to use your solution and I am trying to install the requirements following the instructions.

However I get this error message 👇🏻 I already tried it with python 3.11, 3.12, and 3.13.
image

Suggestions on how to solve it?

@WailerG
Copy link

WailerG commented Jan 23, 2025

I managed to run it by downloading the folder then run it directly in Jupyter Notebook:

from argparse import Namespace
import os
import sys
import pandas as pd
import numpy as np

pd.set_option('display.max_columns', None) # Show all columns
pd.set_option('display.expand_frame_repr', False) # Prevent line wrapping
pd.set_option('display.max_colwidth', None) # Show full column content

Set up MagnetoPy paths

current_path = os.getcwd()
print(f"Current working directory: {current_path}")
magnetopy_path = os.path.join(current_path, "MagnetoPy")

if magnetopy_path not in sys.path:
sys.path.append(magnetopy_path)

try:
from src.magnetopy.magnetopy_core.diurnal_variation import DiurnalVariation
from src.magnetopy.magnetopy_core.calculate_igrf import CalculateIGRF
print("Modules imported successfully!")
except ModuleNotFoundError as e:
print(f"Import failed: {e}")
sys.exit(1)

Input file paths

stations_file = os.path.join(current_path, "dataset", "field_measurements.csv")
base_station_file = os.path.join(current_path, "dataset", "base_stations.csv")

Ensure the input files exist

if not os.path.exists(stations_file):
print(f"Error: Stations file not found: {stations_file}")
sys.exit(1)

if not os.path.exists(base_station_file):
print(f"Error: Base station file not found: {base_station_file}")
sys.exit(1)

Namespace arguments

output_folder = os.path.join(current_path, "resources", "Kurdistan")
output_filename = 'DiurnalVariation_Kurdistan_output.csv'

arguments = Namespace(
project_name='Kurdistan', #Project name (required).
stations_file=stations_file, #Stations file path containing date, time, magfield, latitude and longitude data of the study (required).
stations_cols='date,time,gpslat,gpslon,magfield', #Stations file columns names in the following order: date, time, latitude, longitude and magnetic_field (required).
base_station_file=base_station_file, #Base station file path containing date, time and magfield of the study (required).
base_station_cols='date,time,magfield', #Base station columns names in the following order: date, time and magnetic_field (required).
output_folder=output_folder, # Output folder explicitly set
output_filename=output_filename # Explicitly define the output file name
)

Run DiurnalVariation

try:
DiurnalVariation(arguments=arguments)
print(f"DiurnalVariation completed successfully. Output saved to: {os.path.join(output_folder, output_filename)}")
except Exception as e:
print(f"Error: DiurnalVariation failed with error: {e}")
sys.exit(1)

@JCBucio
Copy link
Owner

JCBucio commented Jan 27, 2025

Hello @leomiquelutti, thank you very much for using MagnetoPy and writing to me. Apologies for the delay in responding.

Reviewing the error you mention, it seems to me that it is caused by the version I previously had of matplotlib, I just updated it in the requirements.txt, I went from version 3.9.1 to the most current one (3.10.0). You can do a git pull to update the project.

This should solve your error, if it doesn't work you can write to me here or directly to my email ([email protected]) and we will find a way to solve it. In case this solves your error, could you help me by closing this issue?

Thank you very much for your solution @WailerG, it is also an option to import the modules directly into a Jupyter Notebook.

Again, apologies for the delay.

Greetings from Mexico! 🇲‍🇽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants