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

spedas / pyspedas / 16972251084

14 Aug 2025 05:28PM UTC coverage: 89.527% (+0.01%) from 89.515%
16972251084

push

github

jameswilburlewis
Tweaked wording and formatting for readthedocs

40100 of 44791 relevant lines covered (89.53%)

0.9 hits per line

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

66.67
/pyspedas/pytplot/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
1✔
7
import pyspedas
1✔
8
from pyspedas.pytplot import store_data
1✔
9
from copy import deepcopy
1✔
10
from collections import OrderedDict
1✔
11

12

13
def tplot_copy(old_name, new_name):
1✔
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):
1✔
38
        if isinstance(pyspedas.pytplot.data_quants[old_name], dict):
×
39
            old_name = pyspedas.pytplot.data_quants[old_name]['name']
×
40
        else:
41
            old_name = pyspedas.pytplot.data_quants[old_name].name
×
42

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

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

56
    return
1✔
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