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

Calculating potentials at any coordinate #367

Merged
merged 4 commits into from
Jan 23, 2024

Conversation

billetd
Copy link
Contributor

@billetd billetd commented Jan 22, 2024

This PR implements a new method calulate_potentials_pos() for calculating the electric potentials at any given magnetic latitude and magnetic longitude. The code is mostly ripped from calculate_potentials(), but adjusted slightly / cleaned up so that there is no pre-defined grid (for plotting), and so that mlat/mlon can be given as inputs.

Approval

2

Test

import pydarn


mapfile = '20230123.n.map'

SDarn_read = pydarn.SuperDARNRead(mapfile)
map_data = SDarn_read.read_map()

# Coordinates of interest, as mlat/mlon pairs. 
#This example keeps mlon the same but changes mlat, like a keogram
mlats = [75, 76, 77, 78] 
mlons = [110, 110, 110, 110]

# Map parameters from the mapfile, first record
fit_coefficient = map_data[0]['N+2']
fit_order = map_data[0]['fit.order']
lat_shift = map_data[0]['lat.shft']
lon_shift = map_data[0]['lon.shft']
lat_min = map_data[0]['latmin']
hemisphere = pydarn.Hemisphere(map_data[0]['hemisphere'])

# Get the potentials for my coordinates
pots = pydarn.Maps.calculate_potentials_pos(mlats, mlons, fit_coefficient, lat_min, lat_shift, lon_shift,
                                            fit_order, hemisphere)

Method for calculating the electric potentials at a given coordinate
@bharatreddy bharatreddy self-assigned this Jan 22, 2024
@bharatreddy
Copy link
Collaborator

There was a very minor indentation problem, I fixed it. The rest of the code works great for me for multiple map2 files.

Copy link
Collaborator

@carleyjmartin carleyjmartin left a comment

Choose a reason for hiding this comment

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

Just some style changes and a fix for single float values which was breaking for me as it expected a list.
Working well!

@carleyjmartin carleyjmartin merged commit c3e8979 into develop Jan 23, 2024
@carleyjmartin carleyjmartin deleted the ehn/potentials_coordinates branch January 23, 2024 14:49
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

Successfully merging this pull request may close these issues.

3 participants