• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

spedas / pyspedas / 25391193746

05 May 2026 05:15PM UTC coverage: 76.027% (+19.6%) from 56.446%
25391193746

push

github

jameswilburlewis
Restore Cluster tests -- CSA seems to be back online

37244 of 48988 relevant lines covered (76.03%)

2.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/pyspedas/tplot_tools/tplot_copy.py
1
# Copyright 2020 Regents of the University of Colorado. All Rights Reserved.
2
# Released under the MIT license.
3
# This software was developed at the University of Colorado's Laboratory for Atmospheric and Space Physics.
4
# Verify current version before use at: https://github.com/MAVENSDC/PyTplot
5

6
import logging
4✔
7
import pyspedas
4✔
8
from pyspedas.tplot_tools import store_data
4✔
9
from copy import deepcopy
4✔
10
from collections import OrderedDict
4✔
11

12

13
def tplot_copy(old_name, new_name):
4✔
14
    """
15
    This function will copy a tplot variables that is already stored in memory.
16

17
    Parameters
18
    ----------
19
        old_name : str
20
            Old name of the Tplot Variable
21
        new_name : str
22
            Name of the copied Tplot Variable
23

24
    Returns
25
    -------
26
        None
27

28
    Examples
29
    --------
30
        >>> # Copy Variable 1 into a new Variable 2
31
        >>> import pyspedas
32
        >>> pyspedas.tplot_copy("Variable1", "Variable2")
33

34
    """
35

36
    # if old name input is a number, convert to corresponding name
37
    if isinstance(old_name, int):
4✔
38
        if isinstance(pyspedas.tplot_tools.data_quants[old_name], dict):
×
39
            old_name = pyspedas.tplot_tools.data_quants[old_name]['name']
×
40
        else:
41
            old_name = pyspedas.tplot_tools.data_quants[old_name].name
×
42

43
    # check if old name is in current dictionary
44
    if old_name not in pyspedas.tplot_tools.data_quants.keys():
4✔
45
        logging.info("The name %s is currently not in pyspedas",old_name)
×
46
        return
×
47

48
    # Add a new data quantity with the copied data
49
    if isinstance(pyspedas.tplot_tools.data_quants[old_name], dict):
4✔
50
        # old variable is a non-record varying variable
51
        store_data(new_name, data={'y': pyspedas.tplot_tools.data_quants[old_name]['data']})
×
52
    else:
53
        pyspedas.tplot_tools.data_quants[new_name] = deepcopy(pyspedas.tplot_tools.data_quants[old_name])
4✔
54
        pyspedas.tplot_tools.data_quants[new_name].name = new_name
4✔
55

56
    return
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc