What is ‘…’ in HTML?

… is the HTML entity code for the ellipsis dots:

If you see it on a webpage outside the HTML source code, it usually means that the author or content management system has encoded the HTML entity incorrectly. You should only ever see on the page except in literal HTML sourcecode.

I recommend using the unicode character HORIZONTAL ELLIPSIS (see the code block above) instead of the HTML entity …. Ensure that you have

<meta charset="utf-8" />

in your HTML <head> for compatibility.

Posted by Uli Köhler in HTML

What is performance criterion A/B/C/D in EMI tests?

When doing EMI immunity tests, you will often encounter specifications that your device should e.g. “meet Performance Criterion B during the ESD test”.

The performance criteria, as defined in the IEC 61000 series of standards, e.g. IEC 61000-4-5:2014 (surge test standard) are:

  • Performance Criterion A: Your device continues to function normally during the test (i.e. no interruption)
  • Performance Criterion B: Your device shows a malfunction but recovers automatically  (without user interaction) and then continues to operate normally.
  • Performance Criterion C: Your devices shows a malfunction, but continues to operate normally only after user interaction (e.g. the user resets the device)
  • Performance Criterion D: Your device has a permanent malfunction (e.g. some part of its hardware has been destroyed, or data being lost) which cannot be recovered from even after user interaction.

Additionally note that your device must not become dangerous under any circumstances, even if destroyed as per Performance Criterion D.

What defines a malfunction is up to the manufacturer of the device, but usually it’s related to whatever function it is advertised to perform. The manufacturer should define

Example: 230V LED bulb

  • Performance Criterion A: LED Bulb continues to operate normally after the test
  • Performance Criterion B: Bulb flickers during the test, but operates normally after the test
  • Performance Criterion B: Bulb is less bright during the test but then operates normally.
  • Performance Criterion B: Bulb blinks 10 times slowly but then operates normally
  • Performance Criterion B: Bulb stays off for 20 seconds after the test but then goes back to normal.
  • Performance Criterion C: Bulb goes out, but works normally after you switch off and on the power
  • Performance Criterion C: Bulb continues to blink, but works normally after you switch off and on the power
  • Performance Criterion D: Bulb goes out and does not turn on after you switch off and on the power
  • Performance Criterion D: Bulb blinks after the test and continues to blink even if you switch off and on the power.

As a manufacturer you could define e.g.

  • that the light intensity should be judged by eye (i.e. it should not be significantly dimmer after the test than a new bulb)
  • that a luxmeter needs to be used to judge the light intensity after tests
  • that the bulb may stay off for at most 15 seconds

and so on. In all but the most demanding applications, manufacturers define the criteria conservatively in order to increase the likelihood of passing the test. Since EMI laboratory tests are expensive, it’s in your best interest as a manufacturer not to over-define the criteria.

Posted by Uli Köhler in Electronics, EMI

How to fix LaTeX missing footnotes in tabular environment

Problem:

You have LaTeX code with a \footnote inside a \tabular like this:

\documentclass{scrartcl}

\begin{document}
\begin{tabular}{p{2cm}|p{2cm}|}
\textbf{Column A\footnote{This is a footnote!}} & \textbf{Column B}\\
1 & 2\\
3 & 4\\
\end{tabular}
\end{document}

but LaTeX/PDFLaTeX is not showing any of the footnotes you declared inside the \tabular environment.

Solution:

Use this code just after your \documentclass declaration:

\usepackage{footnote}
\makesavenoteenv{tabular}

Then recompile your LaTeX code. The footnotes inside your tabular should now appear as expected.

Note that if you are using other environments than \begin{tabular} you might need to add more \makesavenoteenv declarations for the correct environments. The tabularx environment from the tabularx package works with footnotes out-of-the box without any additional packages!

 

Posted by Uli Köhler in LaTeX

How to fix LaTeX \glqq or \grqq error ‘Undefined control sequence’

Problem:

You have LaTeX code containing \glqq and/or \grqq like

\documentclass{scrartcl}

\begin{document}
\glqq Test\grqq
\end{document}

but when you try to compile it, you see an error message like this:

! Undefined control sequence.
l.5 \glqq
          Test\grqq
? 

Solution:

In order to use \glqq or \grqq you need to include

\usepackage[ngerman]{babel}

after your \documentclass declaration.

In case you want to use another language, use the correct language specifier instead of ngerman.

Posted by Uli Köhler in LaTeX

How to create a self-deleting temporary directory in Python

Starting from Python 3.2 your can use tmpfile.TemporaryDirectory like this:

from tempfile import TemporaryDirectory

with TemporaryDirectory(prefix="myapp-") as tmpdir:
    print(tmpdir) # e.g. "/tmp/myapp-fevhzh93"

# Once you are outside the "with" block, the directory will be deleted!

In case you are stuck with using older Python versions, check out How to create temporary directory in Python.

Posted by Uli Köhler in Python

How to convert a PDF file to SVG on the command line

If you want to convert my.pdf to my.svg, use eps2svg like this:

eps2svg my.eps

Even though the name eps2svg may suggest it can only read EPS files, the program will handle PDFs just fine!

This command produces my.svg – note that if my.svg already exists, eps2svg will create my_1.svg, my_2.svg and so on and will not overwrite my.svg!

You can also use this shell function:

function pdf2svg { eps2svg "${1%.*}.eps" "${1%.*}.svg" ; }

This will always produce my.svg, overwriting it if it already exists!

Usage example:

pdf2svg my.pdf # Produces my.svg

 

Posted by Uli Köhler in Linux

How to insert € symbol in LaTeX using UTF8

Note: This is the recommended method for using and other symbols in LaTeX!

In order to insert the symbol into your LaTeX document, first add

\usepackage[official]{eurosym}
\usepackage[utf8x]{inputenc}

to the top of your document, e.g. directly after your \documentclass line.

After that, you can use the normal symbol anywhere in your document like this:

to insert an symbol.

 

 

Posted by Uli Köhler in LaTeX

How to insert € symbol in LaTeX using the eurosym package

Note: This method is no longer recommended and only provided for compatibility reasons! See How to insert Euro symbol in LaTeX using UTF8 for the recommended method instead!

In order to insert the symbol into your LaTeX document, first add

\usepackage[official]{eurosym}

to the top of your document, e.g. directly after your \documentclass line.

After that, you can use

\euro{}

to insert an symbol anywhere in your document.

 

Posted by Uli Köhler in LaTeX

How to reduce page margins in LaTeX using the geometry package

To set or reduce the page margin (white space between the border of the page and the text) you can use the geometry package.

Set margin of all sides to 2cm:

\usepackage[left=20mm, right=20mm, top=20mm, bottom=20mm]{geometry}

To set just the left and right margin to 2cm, use

\usepackage[left=20mm, right=20mm]{geometry}

 

Posted by Uli Köhler in LaTeX

How to convert a DVI file to SVG on the command line

If you want to convert my.dvi to my.svg, use this command

dvi2ps my.dvi | ps2eps - > my.eps && eps2svg my.eps

This produces my.svg – note that if my.svg already exists, eps2svg will create my_1.svg, my_2.svg and so on and will not overwrite my.svg!

You can also use this shell function:

function dviToSVG { dvi2ps "$1" | ps2eps - > "${1%.*}.eps" && eps2svg "${1%.*}.eps" "${1%.*}.svg" ; }

Usage example:

dviToSVG my.dvi # Produces my.svg

 

Posted by Uli Köhler in LaTeX, Linux, Shell

Minimal LaTeX booktabs example

This is a minimal example using the LaTeX booktabs package which you can use & modify to create your own table.

\documentclass{scrartcl}
\usepackage{booktabs}
\usepackage[utf8x]{inputenc}

\begin{document} 

\begin{table}[h!]
    \begin{center}
      \caption{Minimal booktabs example.}
      \label{tab:table1}
      \begin{tabular}{l|c|r}
        \toprule % <-- Toprule here
        \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3}\\
        $\alpha$ & $\beta$ & $\gamma$ \\
        \midrule % <-- Midrule here
        A & 10.23 & a\\
        B & 45.678 & b\\
        C & 99.987 & c\\
        \bottomrule % <-- Bottomrule here
      \end{tabular}
    \end{center}
  \end{table}
\end{document}

Render it using

pdflatex booktabs.tex

The table looks like this:

Posted by Uli Köhler in LaTeX

How to fix LaTeX error File `siunitx.sty’ not found on Ubuntu

Problem:

You want to compile your LaTeX file on Ubuntu using latex or pdflatex but you see an error message like this:

! LaTeX Error: File `siunitx.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Solution

sudo apt -y install texlive-science

This will install, among many other LaTeX files, siunitx.sty.

Posted by Uli Köhler in LaTeX

Inductive reactance online calculator & Python code

Use this online calculator to compute the reactance of an inductor in Ω at a specific frequency given its inductance.

Also see Capacitive reactance online calculator & Python code

TechOverflow calculators:
You can enter values with SI suffixes like 12.2m (equivalent to 0.012) or 14k (14000) or 32u (0.000032).
The results are calculated while you type and shown directly below the calculator, so there is no need to press return or click on a Calculate button. Just make sure that all inputs are green by entering valid values.

H

Hz

Formula:

X_L = 2\pi fL

Python code:

The preferred way is to use UliEngineering’s UliEngineering.Electronics.Reactance.inductive_reactance:

from UliEngineering.Electronics.Reactance import *
# You can either pass strings like "150 uH" or values like 150e-6

inductive_reactance("150 uH", "10 MHz") # returns 9424.77796076938

Or get a human-readable value:

from UliEngineering.Electronics.Reactance import *
from UliEngineering.EngineerIO import *

# Compute value as a string
xc = auto_format(inductive_reactance, "150 uH", "10 MHz") # "9.42 kΩ"

# ... or print directly
auto_print(inductive_reactance, "150 uH", "10 MHz") # prints "9.42 kΩ"

In case you can’t use UliEngineering and you want to do it manually, here’s a minimal example:

import math
def inductive_reactance(f, l):
    """Compute the inductive reactance"""
    return 2*math.pi*f*l
Posted by Uli Köhler in Calculators, Electronics, Python

Capacitive reactance online calculator & Python code

Use this online calculator to compute the reactance of a capacitor in Ω at a specific frequency given its capacitance.

Also see Inductive reactance online calculator & Python code

TechOverflow calculators:
You can enter values with SI suffixes like 12.2m (equivalent to 0.012) or 14k (14000) or 32u (0.000032).
The results are calculated while you type and shown directly below the calculator, so there is no need to press return or click on a Calculate button. Just make sure that all inputs are green by entering valid values.

F

Hz

Formula:

X_C = \frac{1}{2\pi fC}

Python code:

The preferred way is to use UliEngineering’s UliEngineering.Electronics.Reactance.capacitive_reactance:

from UliEngineering.Electronics.Reactance import *
# You can either pass strings like "150 pF" or values like 150e-12

capacitive_reactance("150 pF", "10 MHz") # returns 106.1032953945969

Or get a human-readable value:

from UliEngineering.Electronics.Reactance import *
from UliEngineering.EngineerIO import *

# Compute value as a string
xc = auto_format(capacitive_reactance, "150 pF", "10 MHz") # "106 Ω"

# ... or print directly
auto_print(capacitive_reactance, "150 pF", "10 MHz") # prints "106 Ω"

In case you can’t use UliEngineering and you want to do it manually, here’s a minimal example:

import math
def capacitive_reactance(f, c):
    """Compute the capacitive reactance"""
    return 1./(2*math.pi*f*c)
Posted by Uli Köhler in Calculators, Electronics, Python

Volts to dBµV online calculator & Python code

Use this online calculator to convert a voltage in Volts to a voltage in dBµV.

Also see dBµV to Volts online calculator & Python code

TechOverflow calculators:
You can enter values with SI suffixes like 12.2m (equivalent to 0.012) or 14k (14000) or 32u (0.000032).
The results are calculated while you type and shown directly below the calculator, so there is no need to press return or click on a Calculate button. Just make sure that all inputs are green by entering valid values.

V

Formula:

U_{\text{dBµV}} = \frac{20\cdot\log(1\,000\,000 \cdot U_V)}{ \log(2) + \log(5)}

Python code:

import math
def volts_to_dbuv(v):
    """Convert a voltage in volts to a voltage in dBµV"""
    return (20*math.log(1e6 * v))/(math.log(2) + math.log(5))

 

Posted by Uli Köhler in Calculators, Electronics

How to fix Matplotlib ‘ AttributeError: module matplotlib.pyplot’ has no attribute ‘yrange’

Problem:

You are trying to set the range of the Y axis of a matplotlib plot using code like

plt.yrange([0.0, 10.0])

but you see an error message like this:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-aa38a78ab5d7> in <module>
     12 plt.xscale('log')
     13 plt.grid(True, which="both")
---> 14 plt.yrange([0.0, 70.])
     15

AttributeError: module 'matplotlib.pyplot' has no attribute 'yrange'

Solution:

You need to use ylim since yrange does not exist! The equivalent call is:

plt.ylim([0.0, 10.0])

 

Posted by Uli Köhler in Python

Slope-intercept form from two points online calculator

TechOverflow calculators:
You can enter values with SI suffixes like 12.2m (equivalent to 0.012) or 14k (14000) or 32u (0.000032).
The results are calculated while you type and shown directly below the calculator, so there is no need to press return or click on a Calculate button. Just make sure that all inputs are green by entering valid values.

First point:

X

Y

First point:

X

Y


Formulae:

m = \frac{y_2 - y_1}{x_2 - x_1} a = y_1 - m\cdot x_1 y = m\cdot x + a
Posted by Uli Köhler in Calculators, Mathematics

dBµV to Volts online calculator & Python code

Use this online calculator to convert a voltage in dBµV to a voltage in Volts.

Also see Volts to dBµV online calculator & Python code

TechOverflow calculators:
You can enter values with SI suffixes like 12.2m (equivalent to 0.012) or 14k (14000) or 32u (0.000032).
The results are calculated while you type and shown directly below the calculator, so there is no need to press return or click on a Calculate button. Just make sure that all inputs are green by entering valid values.

dBµV

Formula:

U_{\text{Volts}} = \frac{10^{\frac{U_{dBµV}}{20}}}{1\,000\,000 \frac{V}{µV}}

Python code:

def dbuv_to_volts(dbuv):
    """Convert a voltage in dBµV to a voltage in volts"""
    return (10**(dbuv/20.))/1e6

 

Posted by Uli Köhler in Calculators, Electronics

Pure Javascript equivalent to jQuery $(document).ready()

The pure Javascript equivalent to

$(document).ready(function() {
    // Your code goes here!

})

is

document.addEventListener("DOMContentLoaded", function() { 
    // Your code goes here!
});

Note that it’s not supported by IE8, but that should not be an issue in 2019.

Posted by Uli Köhler in Javascript

How to write BytesIO content to file in Python

In order to write the contents of a BytesIO instance to a file, use this snippet:

with open("out.txt", "wb") as outfile:
    # Copy the BytesIO stream to the output file
    outfile.write(myio.getbuffer())

Note that getbuffer() will not create a copy of the values in the BytesIO buffer and will hence not consume large amounts of memory.

You can also use this function:

def write_bytesio_to_file(filename, bytesio):
    """
    Write the contents of the given BytesIO to a file.
    Creates the file or overwrites the file if it does
    not exist yet. 
    """
    with open(filename, "wb") as outfile:
        # Copy the BytesIO stream to the output file
        outfile.write(bytesio.getbuffer())

Full example:

#!/usr/bin/env python3
from io import BytesIO
import shutil

# Initialie our BytesIO
myio = BytesIO()
myio.write(b"Test 123")

def write_bytesio_to_file(filename, bytesio):
    """
    Write the contents of the given BytesIO to a file.
    Creates the file or overwrites the file if it does
    not exist yet. 
    """
    with open(filename, "wb") as outfile:
        # Copy the BytesIO stream to the output file
        outfile.write(bytesio.getbuffer())

write_bytesio_to_file("out.txt", myio)

 

Posted by Uli Köhler in Python
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPTPrivacy &amp; Cookies Policy