other:python:misc_by_jyp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
other:python:misc_by_jyp [2022/12/12 15:24] – Added the global variables section jypeter | other:python:misc_by_jyp [2023/04/27 17:52] – [Data representation] Improved jypeter | ||
---|---|---|---|
Line 32: | Line 32: | ||
< | < | ||
+ | ===== Data representation ===== | ||
+ | A few notes for a future section or page about about //data representation// | ||
+ | |||
+ | * Binary data representation of some numbers: | ||
+ | * [[https:// | ||
+ | * Range: | ||
+ | * 4-byte integers ('' | ||
+ | * 8-byte integers ('' | ||
+ | * Tech note: signed integers use [[https:// | ||
+ | * [[https:// | ||
+ | * Range: | ||
+ | * 4-byte float ('' | ||
+ | * See also [[https:// | ||
+ | * 8-byte float ('' | ||
+ | * Special values: | ||
+ | * [[https:// | ||
+ | * Infinity ('' | ||
+ | * Note: it is cleaner to use masks (and [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * A rather technical example: we //play// with a numpy 4-byte integer scalar | ||
+ | * < | ||
+ | >>> | ||
+ | 1 | ||
+ | >>> | ||
+ | <class ' | ||
+ | >>> | ||
+ | dtype(' | ||
+ | >>> | ||
+ | () | ||
+ | >>> | ||
+ | Traceback (most recent call last): | ||
+ | File "< | ||
+ | IndexError: invalid index to scalar variable. | ||
+ | >>> | ||
+ | 1 | ||
+ | >>> | ||
+ | 0 | ||
+ | >>> | ||
+ | 1 | ||
+ | >>> | ||
+ | 4 | ||
+ | >>> | ||
+ | ' | ||
+ | >>> | ||
+ | ' | ||
+ | >>> | ||
+ | ' | ||
+ | |||
+ | # ' | ||
+ | # Note: the serialized data seems to be printed in the reverse order of ' | ||
+ | >>> | ||
+ | >>> | ||
+ | <class ' | ||
+ | >>> | ||
+ | 4 | ||
+ | >>> | ||
+ | b' | ||
+ | >>> | ||
+ | '01 00 00 00' | ||
+ | |||
+ | # Use the following in the unlikely case where you need to change the endianness (bytes ordering) | ||
+ | >>> | ||
+ | >>> | ||
+ | 16777216 | ||
+ | >>> | ||
+ | ' | ||
+ | >>> | ||
+ | b' | ||
+ | * Another technical example: we use an array of 2 integers\\ When using '' | ||
+ | * < | ||
+ | >>> | ||
+ | array([ 3, 17], dtype=int32) | ||
+ | >>> | ||
+ | ((2,), 1, 2, 8) | ||
+ | >>> | ||
+ | ' | ||
+ | >>> | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | * Array addressing | ||
+ | * python/C vs Fortran... | ||
+ | |||
+ | * disk and ram usage: how to check the usage (available ram and disk), best practice on multi-user systems (how much allowed?) | ||
+ | * '' | ||
+ | |||
+ | * understanding and reverse-engineering //binary// format | ||
+ | * '' | ||
+ | |||
+ | * binary vs text format: ascii, utf, raw | ||
+ | * text related functions in python: '' | ||
+ | * lists conversion with '' | ||
+ | |||
+ | * Misc : '' | ||
===== Checking if a file/ | ===== Checking if a file/ | ||
Line 453: | Line 548: | ||
>>> | >>> | ||
array([3. , 4.5, 8. ])</ | array([3. , 4.5, 8. ])</ | ||
+ | |||
+ | |||
+ | ===== matplotlib related stuff ===== | ||
+ | |||
+ | ==== Working with time axes (and ticks) ==== | ||
+ | |||
+ | If you have problems setting the limits of a time axis, choosing the ticks' locations, or specifying the style of the labels, you should check the: | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
other/python/misc_by_jyp.txt · Last modified: 2024/11/04 15:01 by jypeter