SuperDARN / pydarn

Python library for visualizing SuperDARN Data
GNU Lesser General Public License v3.0
31 stars 11 forks source link

Calculating potentials at any coordinate #367

Closed billetd closed 7 months ago

billetd commented 7 months ago

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)
bharatreddy commented 7 months ago

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