@@ -44,6 +44,7 @@ def gmag(
4444 no_update = False ,
4545 time_clip = False ,
4646 force_download = False ,
47+ sampling_rate = 1 ,
4748):
4849 """
4950 Load ground magnetometer data from the THEMIS mission.
@@ -84,7 +85,9 @@ def gmag(
8485 force_download: bool, optional
8586 Download file even if local version is more recent than server version
8687 Default: False
87-
88+ sampling_rate: int, optional
89+ Specify a sampling rate for loading variometer data. Accepts 1 (Hz) or 10 (Hz).
90+ Default: 1
8891 Returns
8992 -------
9093 dict
@@ -94,10 +97,28 @@ def gmag(
9497 --------
9598 >>> from pyspedas.projects.themis import gmag
9699 >>> from pyspedas import tplot
100+ >>> from pyspedas import subtract_median
97101 >>>
98102 >>> # Load ground magnetometer data for specific sites and time range
99103 >>> gmag_vars = gmag(sites=['ccnv','bmls'], trange=['2013-11-05', '2013-11-06'])
100104 >>> tplot(['thg_mag_bmls', 'thg_mag_ccnv'])
105+ >>>
106+ >>> # Load variometer data for specific sites and time range:
107+ >>> gmag_vars = gmag(sites=['s61a','anmo'], trange=['2026-02-24', '2026-02-25'])
108+ >>> subtract_median(['thg_mag_s61a', 'thg_mag_anmo'])
109+ >>> tplot(['thg_mag_s61a-m', 'thg_mag_anmo-m'])
110+ >>>
111+ >>> # Load 10 Hz variometer data for specific sites and time range:
112+ >>> gmag_vars = gmag(sites=['s61a','anmo'], sampling_rate=10, trange=['2026-02-24', '2026-02-25'])
113+ >>> subtract_median(['thg_mag_s61a_100ms', 'thg_mag_anmo_100ms'])
114+ >>> tplot(['thg_mag_s61a_100ms-m', 'thg_mag_anmo_100ms-m'])
115+ >>>
116+ >>> # Load 10 Hz variometer data for specific sites and time range using the 10 Hz file name format:
117+ >>> gmag_vars = gmag(sites=['s61a_100ms','anmo_100ms'], trange=['2026-02-24', '2026-02-25'])
118+ >>> subtract_median(['thg_mag_s61a_100ms', 'thg_mag_anmo_100ms'])
119+ >>> tplot(['thg_mag_s61a_100ms-m', 'thg_mag_anmo_100ms-m'])
120+ >>>
121+
101122 """
102123
103124 if sites is None :
@@ -250,6 +271,48 @@ def gmag(
250271 "weyb" ,
251272 "wgry" ,
252273 ]
274+ variometer_sites = [
275+ "anmo" ,
276+ "casy" ,
277+ "ccm" ,
278+ "cola" ,
279+ "cor" ,
280+ "dgmt" ,
281+ "dwpf" ,
282+ "ecsd" ,
283+ "eymn" ,
284+ "e46a" ,
285+ "e62a" ,
286+ "goga" ,
287+ "hrv" ,
288+ "j47a" ,
289+ "kbs" ,
290+ "kevo" ,
291+ "kono" ,
292+ "ksu1" ,
293+ "k30b" ,
294+ "k50a" ,
295+ "mbwa" ,
296+ "mstx" ,
297+ "m63a" ,
298+ "o20a" ,
299+ "pab" ,
300+ "p57a" ,
301+ "qspa" ,
302+ "rssd" ,
303+ "r49a" ,
304+ "sba" ,
305+ "sfjd" ,
306+ "spmn" ,
307+ "sspa" ,
308+ "s61a" ,
309+ "t47a" ,
310+ "u38b" ,
311+ "wci" ,
312+ "whtx" ,
313+ "wvt" ,
314+ "352a"
315+ ]
253316 sites = (
254317 thm_sites
255318 + tgo_sites
@@ -266,6 +329,7 @@ def gmag(
266329 + fmi_sites
267330 + aair_sites
268331 + carisma_sites
332+ + variometer_sites
269333 )
270334
271335 if group is not None :
@@ -274,6 +338,29 @@ def gmag(
274338 if not isinstance (sites , list ):
275339 sites = [sites ]
276340
341+ # check for sites in Variometer group
342+ variometer = []
343+ for site in sites :
344+ s_rate = check_variometer (site )
345+ # if check_variometer determines site
346+ # to be 1 Hz sampling rate, check if
347+ # sampling_rate argument has been set
348+ if (s_rate == 1 ) and (sampling_rate is not None ):
349+ # if so, pass sampling_rate value
350+ # (case where variometer base names
351+ # are passed, but 10 Hz sampling rate
352+ # data is to be loaded)
353+
354+ # check if sampling_rate is valid:
355+ if sampling_rate not in [1 ,10 ]:
356+ # throw error
357+ logging .error ('sampling_rate must be either 1 or 10. Setting to default value of 1' )
358+ sampling_rate = 1
359+
360+ variometer .append (sampling_rate )
361+ else :
362+ variometer .append (s_rate )
363+
277364 # check for sites in Greenland
278365 greenland = []
279366 for site in sites :
@@ -295,6 +382,7 @@ def gmag(
295382 notplot = notplot ,
296383 stations = sites ,
297384 greenland = greenland ,
385+ variometer = variometer ,
298386 time_clip = time_clip ,
299387 no_update = no_update ,
300388 force_download = force_download ,
@@ -482,3 +570,51 @@ def check_greenland(station_name):
482570 return 1
483571
484572 return 0
573+
574+ def check_variometer (station_name ):
575+ """
576+ Check if a given station belongs to the Variometers group.
577+ If so, check if the given stationname is formatted to request
578+ data in the 10 Hz sampling rate.
579+
580+ Parameters
581+ ----------
582+ station_name : str
583+ The name of the station to check.
584+
585+ Returns
586+ -------
587+ int
588+ Returns sampling rate (1 or 10) if the station is in the variometers group, otherwise returns 0.
589+
590+ Examples
591+ --------
592+ >>> from pyspedas.projects.themis.ground.gmag import check_variometer
593+ >>> check_variometer("s61a")
594+ 1
595+ >>> check_variometer("s61a_100ms")
596+ 10
597+ """
598+
599+ # check if station_name contains "_100ms". If it does,
600+ # create copy of station name with the "_100ms"
601+ # substring removed
602+ if "_100ms" in station_name .lower ():
603+ station_name_base = station_name .lower ()
604+ station_name_base = station_name_base .replace ("_100ms" ,"" )
605+ else :
606+ station_name_base = station_name .lower ()
607+
608+ gmag_dict = themis_gmag_dict .get_gmag_list ()
609+ for station in gmag_dict :
610+ # compare a copy of station name with any "_100ms"
611+ # substring removed with the station ccode
612+ if station ["ccode" ].lower () == station_name_base :
613+ if (
614+ station ["variom" ] is not None and station ["variom" ].lower () == "y"
615+ ):
616+ if "_100ms" in station_name .lower ():
617+ return 10
618+ else :
619+ return 1
620+ return 0
0 commit comments