Update SuperMAG metadata

    Parameters
    -----------
    col_name : (str)
        Data column name

    Returns
    --------
    col_dict : (dict)
       Dictionary of strings detailing the units and long-form name of the data
420267
def update_smag_metadata(col_name):
    

    smag_units = {'IAGA':'none', 'N':'nT', 'E':'nT', 'Z':'nT', 'MLT':'hours',
                  'MLAT':'degrees', 'SZA':'degrees', 'IGRF_DECL':'degrees',
                  'SMU':'none', 'SML':'none', 'datetime':'YYYY-MM-DD HH:MM:SS',
                  'GEOLON':'degrees', 'GEOLAT':'degrees', 'AACGMLON':'degrees',
                  'AACGMLAT':'degrees', 'STATION_NAME':'none',
                  'OPERATOR_NUM':'none', 'OPERATORS':'none'}
    smag_name = {'IAGA':'Station Code', 'N':'B along local magnetic North',
                 'E':'B along local magnetic East', 'Z':'B vertically downward',
                 'MLT':'Magnetic Local Time', 'MLAT':'Magnetic Latitude',
                 'SZA':'Solar Zenith Angle',
                 'IGRF_DECL':'IGRF magnetic declination',
                 'SMU': 'Maximum eastward auroral electrojets strength.\n'
                 'Upper envelope of N-component for stations between 40 and '
                 '80 degrees magnetic north.',
                 'SML':'Maximum westward auroral electrojets strength.\n'
                 'Lower envelope of N-component for stations between 40 and 80'
                 ' degrees magnetic north.', 'datetime':'UT date and time',
                 'GEOLON':'geographic longitude',
                 'GEOLAT':'geographic latitude',
                 'AACGMLON':'Altitude-Adjusted Corrected Geomagnetic longitude',
                 'AACGMLAT':'Altitude-Adjusted Corrected Geomagnetic latitude',
                 'STATION_NAME':'Long form station name',
                 'OPERATOR_NUM':'Number of station operators',
                 'OPERATORS':'Station operator name(s)',}
    
    ackn = "When using this data please include the following reference:\n"
    ackn += "Gjerloev, J. W., The SuperMAG data processing technique, "
    ackn += "Geophys. Res., 117, A09213, doi:10.1029/2012JA017683, 2012\n\n"
    ackn += "For publications and presentations, please include the following"
    ackn += "acknowledgement:\nFor the ground magnetometer data we gratefully "
    ackn += "acknowledge: Intermagnet; USGS, Jeffrey J. Love; CARISMA, PI Ian "
    ackn += "Mann; CANMOS; The S-RAMP Database, PI K. Yumoto and Dr. K. "
    ackn += "Shiokawa; The SPIDR database; AARI, PI Oleg Troshichev; The "
    ackn += "MACCS program, PI M. Engebretson, Geomagnetism Unit of the "
    ackn += "Geological Survey of Canada; GIMA; MEASURE, UCLA IGPP and Florida"
    ackn += " Institute of Technology; SAMBA, PI Eftyhia Zesta; 210 Chain, PI "
    ackn += "K. Yumoto; SAMNET, PI Farideh Honary; The institutes who maintain"
    ackn += " the IMAGE magnetometer array, PI Eija Tanskanen; PENGUIN; AUTUMN,"
    ackn += " PI Martin Connors; DTU Space, PI Dr. Rico Behlke; South Pole and "
    ackn += " McMurdo Magnetometer, PI's Louis J. Lanzarotti and Alan T. "
    ackn += "Weatherwax; ICESTAR; RAPIDMAG; PENGUIn; British Artarctic Survey; "
    ackn += "McMac, PI Dr. Peter Chi; BGS, PI Dr. Susan Macmillan; Pushkov "
    ackn += "Institute of Terrestrial Magnetism, Ionosphere and Radio Wave "
    ackn += "Propagation (IZMIRAN); GFZ, PI Dr. Juergen Matzka; MFGI, PI B. "
    ackn += "Heilig; IGFPAS, PI J. Reda; University of L’Aquila, PI M. "
    ackn += "Vellante; BCMT, V. Lesur and A. Chambodut; Data obtained in "
    ackn += "cooperation with Geoscience Australia, PI Marina Costelloe; "
    ackn += "SuperMAG, PI Jesper W. Gjerloev."
    
    col_dict = {'units':smag_units[col_name], 'long_name':smag_name[col_name],
                'acknowledgements':ackn}

    return col_dict
781417
private static String getColumnName(ResultSetMetaData metaData, int idx, EColumnNameCase nameCase) throws SQLException {
		String colName = metaData.getColumnName(idx);
		switch (nameCase) {
			case LOWER:
				colName = colName.toLowerCase();
				break;
			case UPPER:
				colName = colName.toUpperCase();
				break;
		}

		return colName;
	}
61751
def get_display_name_metadata(self):
        
        metadata = dict(self._mdata['display_name'])
        metadata.update({'existing_string_values': self._my_map['displayName']['text']})
        return Metadata(**metadata)
55021
def update(self, values, **context):
        
        schema = self.schema()
        column_updates = {}
        other_updates = {}
        for key, value in values.items():
            try:
                column_updates[schema.column(key)] = value
            except orb.errors.ColumnNotFound:
                other_updates[key] = value

        # update the columns in order
        for col in sorted(column_updates.keys(), key=lambda x: x.order()):
            self.set(col, column_updates[col], **context)

        # update the other values
        for key, value in other_updates.items():
            try:
                self.set(key, value, **context)
            except orb.errors.ColumnValidationError:
                pass

        return len(values)
1234829
def gmean_(self, col: str, index_col: bool=True) -> "Ds":
        
        try:
            df = self.df.copy()
            df = df.groupby([col]).mean()
            if index_col is True:
                df[col] = df.index.values
            return self._duplicate_(df)
        except Exception as e:
            self.err(e, self.gmean_, "Can not meansum column")
673254
def _update_metadata(self):
        
        self._pystratum_metadata['routine_name'] = self._routine_name
        self._pystratum_metadata['designation'] = self._designation_type
        self._pystratum_metadata['table_name'] = self._table_name
        self._pystratum_metadata['parameters'] = self._parameters
        self._pystratum_metadata['columns'] = self._columns
        self._pystratum_metadata['fields'] = self._fields
        self._pystratum_metadata['column_types'] = self._columns_types
        self._pystratum_metadata['timestamp'] = self._m_time
        self._pystratum_metadata['replace'] = self._replace
        self._pystratum_metadata['pydoc'] = self._doc_block_parts_wrapper
1157170
def _update_metadata(self, kwargs=None):
        '''
        '''

        # If not given metadata, use instance.list to get it for container
        if kwargs == None and hasattr(self, 'name'):
            kwargs = self._list(self.name, quiet=True, return_json=True)

        # Add acceptable arguments
        for arg in ['pid', 'name']:

           # Skip over non-iterables:
           if arg in kwargs:
               setattr(self, arg, kwargs[arg])
       
        if "image" in kwargs:
            self._image = kwargs['image']
        elif "container_image" in kwargs:
            self._image = kwargs['container_image']
633137
def _rewrite_col(self, col):
        """"""
        if isinstance(col, Col):
            new_name = rewrite_lookup_key(self.model, col.target.name)
            if col.target.name != new_name:
                new_field = self.model._meta.get_field(new_name)
                if col.target is col.source:
                    col.source = new_field
                col.target = new_field
        elif hasattr(col, 'col'):
            self._rewrite_col(col.col)
        elif hasattr(col, 'lhs'):
            self._rewrite_col(col.lhs)
303319
def metadata
      warn 'metadata is deprecated. Use column_properties[] instead'
      @column_properties.inject({}){|res, (k, v)| res.merge!({k => v.to_h})}
    end
346957
def col_rename(df,col_name,new_col_name):
    
    col_list = list(df.columns)
    for index,value in enumerate(col_list):
        if value == col_name:
            col_list[index] = new_col_name
            break
    df.columns = col_list
1137843
def __create_chron_cols(metadata):
        
        chron_col_list = []
        chron_col_ct = 1
        for variableName, unit in metadata.items():
            temp_dict = OrderedDict()
            temp_dict['column'] = chron_col_ct
            temp_dict['variableName'] = variableName
            temp_dict['unit'] = unit
            chron_col_list.append(copy.deepcopy(temp_dict))
            chron_col_ct += 1

        return chron_col_list
963065
def transform(self, col):
        
        out = pd.DataFrame(index=col.index)
        out[self.col_name] = col.fillna(self.default_value)
        out[self.new_name] = (pd.notnull(col) * 1).astype(int)
        return out
1234635
def rename(self, source_col: str, dest_col: str):
        
        try:
            self.df = self.df.rename(columns={source_col: dest_col})
        except Exception as e:
            self.err(e, self.rename, "Can not rename column")
            return
        self.ok("Column", source_col, "renamed")
526857
def col_mod(df,col_name,func,*args,**kwargs):
    
    backup = df[col_name].copy()
    try:
        return_val = func(df,col_name,*args,**kwargs)
        if return_val is not None:
            set_col(df,col_name,return_val)
    except:
        df[col_name] = backup
158192
def replace_uuid_w_names(self, resp):
        
        
        col_mapper = self.get_point_name(resp.context)["?point"].to_dict()
        resp.df.rename(columns=col_mapper, inplace=True)
        return resp
1023194
def col2name(col_item):
  ""
  if isinstance(col_item, sqparse2.NameX): return col_item.name
  elif isinstance(col_item, sqparse2.AliasX): return col_item.alias
  else: raise TypeError(type(col_item), col_item)
470884
def get_columns(model=None, fields=None, meta=None):
    
    if model:
        M = get_model(model)
    else:
        M = None
    if fields is not None:
        f = fields

    if M:
        if meta and hasattr(M, meta):
            m = getattr(model, meta)
            if hasattr(m, 'fields'):
                f = m.fields
            else:
                f = M._fields_list
        else:
            f = M._fields_list

    columns = []
    for x in f:
        if isinstance(x, str):  # so x is field_name
            field_name = x
        elif isinstance(x, dict):
            field_name = x['name']
        else:
            raise UliwebError("Field definition is not right, it should be just like str or {'name':xxx}")

        if '.' in field_name:
            model_name, field_name = field_name.split('.')
            M = get_model(model_name)

        if not M:
            raise UliwebError("Model can't be empty, because field name not has `model.` prefix")

        if field_name in M.c:
            columns.append(M.c[field_name])

    return columns