You can sort of view the process of building a webpage like that of making a clay vase on a pottery wheel. The html is like the physical structure of the vase that you sculpt on the wheel. You have some flexibility with the shape of the vase but ultimately what makes it unique and beautiful is the glaze that you put on it after its been fired. The glaze then is kind of like the CSS. It allows you to customize your vase the way you want with the designs and patterns of your choosing. While the shape the vase is essential, the glaze changes it from a functional but dull product into something beautiful. The DOM can be compared the kiln. It takes the vase that you have shaped and glazed and sets it into something useable.
Everything that you see on a web page is ultimately a box, so an easy way of breaking down a website model into its component parts is to visualize boxes around the various parts of the model. For instance if there is a large block of text or an image you could draw a box around it. Then when you have boxed every element of the design you can work on them one at a time in your html and css files.
The box model refers to the fact that everything on a web page is a box inside of a larger box. The term box model is associated with the design and layout of a website, and for instance the CSS box model refers to a box around some html content that is in charge of the how that html code is presented on the actual web page. It is responsible for the margins, padding color and, font, and many other aspects of its given bit of content.
Home


Tone.js Experiment #001
This application uses the
Tone.js Javascript library to play pitches using the Web Audio API. The user
interface uses the
NexusUI Javascript library.
When you click on the "Play" button, a series of tones will play. The pitches are determined by calculating
a Schillinger resultant (see
this article for more
background on resultants).
A resultant is calculated by using two numbers (major generator and minor generator). The major generator should always be greater
than the minor generator.
You can change the major and minor generator values using the sliders (the value is set to the integer portion of the slider value). For
example, 5.3 would be 5. Changing the slider values will change the number of pitches and their value.
To hear the sequence again, refresh the page, then click the button again.
To see the numbers in the resultant array, open the Javascript console. They will be printed after the "Play" button is pushed.
Source for this app is at
Github


Our mission is to empower consumers by offering a free and easily accessible source of information regarding industry transparency and consumer safety. To combat social, financial, and environmental injustices in the agricultural and food service industries,we believe it is our responsibility to inform the public in order to create a food system that is equitable, sustainable, and beneficial for everyone involved.


Datasets
For this tutorial we will be using the following datasets:
Boroughs - New York City boroughs. Download from NYC Planning - Open Data. Choose "Borough Boundaries (Clipped to Shoreline)", under "Borough Boundaries & Community Districts".
NYC Parking Violations - Stopping, standing or parking within a marked bicycle lane. Downloaded from NYC OpenData.
What is Geocoding
Geocoding is the process of taking address data and locating it on a map, giving it geographic coordinates. This process,
as simple as it sounds, requires two important things: first, that the addresses be properly formatted, and second,
a detailed street database, containing the names of all streets, as well as the numbering for each street segment.
In the past
geocoding involved taking a street database, such as the LION Single Line Street Base Map,
and using ArcGIS to build a "street locator" file which would act like a dictionary for the street database. Once the "locator" file
was built, ArcGIS would be able to place the addresses on the map based on the street database.
Even though this process is still
in use, for smaller datasets there are simpler alternatives that use QGIS and bypass getting a detailed street database, as well as
building the "street locator" file. In this tutorial, we will use the MMQGIS plugin
for QGIS, which accesses either the Google Maps Geocoding API or the OpenStreetMap/Nominatum API. The big drawback is that both
these APIs have limits on the number of addresses you can geocode. In the case of the Nominatum API, there is a limit of
1 request per second, and in the case of the Google Maps Geocoding API there is a limit of 50 requests per minute and a maximum
of 2,500 requests per day (per API key).
Even though these limits seem not too stringent, once you have a dataset of a few thousand
addresses you will start facing difficulties. Just as an example, take the dataset of parking violations for New York City for
just October 12, 2016, which contains almost 30,000 entries. If you were to use the Google Maps Geocoding API, it would take
over 10 days at a rate of 2,500 requests per day; or if you used the Nominatum API, it would take more than 8 hours. If you need to geocode
a large amount of addresses, the classic way, using ArcGIS, might still be the most efficient way.
Filtering and Downloading Parking Violations
The first step in this tutorial is to select, filter and download the parking violation data. Just like in the working with point data tutorial we will use the NYC OpenData portal to access, filter and download the data. The main dataset we are looking for is called
Parking Violations Issued - Fiscal Year 2017
. Once you click there , selectView Data
from theExplore Data
dropdown menu.Ideally, we would use the whole dataset, but because of the geocoding rate limits we will have to filter the dataset and just use violations related to parking on a bike lane for October 12, 2016. I have chosen that day for no particular reason other than it is a weekday.
You probably also want to check out the
DOF Parking Violation Codes
file, which explains all the different codes for parking violations. We will be using code48
, which relates toStopping, standing or parking within a marked bicycle lane.
Just like on the working with point data tutorial you should create two filters to select just the data we want:
Violation Code
is
48
Issue Date
is
10/12/2016
Finally, click on the
Export
button at the top right-hand corner of the site and choose theCSV
(comma separated values) format. Your file should start downloading then.If you open your .csv file in Excel or Google Sheets you will see that there are about 390 records.
Formatting Address Data
Most geocoding services take addresses in a specific format, something like Address
City
Zip code
County
State
Country
, or a variation of this.
So the first thing we need to do is make sure the dataset we just downloaded has a much address information as possible in the right format. For this we will use either Microsoft Excel or Google Sheets.
First, open your dataset in Excel or Google Sheets
You will notice that the dataset has a column for
Violation County
, another forHouse Number
and another forStreet Name
. Now, we know that all of these traffic violations occurred in New York City and in New York State, so we can just infer those. However, we still need to combine theHouse Number
and theStreet Name
into one field and transform theViolation County
data into something more than just the initials of the counties.Start by adding 4 new columns to your spreadsheet. It doesn't really matter where you add them (I'm adding them right after the
Street Name
field). Name these columnsAddress
,City
,State
, andCounty
.Now you need to combine the
House Number
column with theStreet Name
one. This operations is called a concatenation. In the firstAddress
cell, write the following formula=X2&" "&Y2
. Here,X2
andY2
refer to the cells where theHouse Number
andStreet Name
fields are located. Verify that this formula worked for the first cell and copy it to the rest of the column.Once you've copied the formula for the rest of the cells in the column (and it has worked), you need to select the whole column
Copy
it and in the same locationright click
and choosePaste Special
and thenValues
. That way you are making sure that the new values are hard-coded and not a formula anymore.For the
City
andState
fields you can just fill them in withNew York
andNY
respectively.Finally, the process to fill in the
County
field is a little more complex:First, if you take a look at the
Violation County
column, you will notice that the way the counties have been coded is not consistent. For example, some of the entries for Brooklyn have been coded asBk
and others asK
, which stands for "Kings County". To solve this and to make all the county codes consistent we need to build a small table and use theVLOOKUP
function.In a separate part of your spreadsheet (I'm doing this on the right hand side), create the following table:
These are all the variations of the county names in the table and their corresponding value. Now we need to write the formula stating that when you find the value on the left, in the
Violation County
column you should fill theCounty
column with the value on the right of the table.In the first cell of the
County
column write the following formula=VLOOKUP(V2,$AW$2:$AX$10,2,FALSE)
. TheV2
refers to where theViolation County
value is, the$AW$2:$AX$10
point to the table we created (the$
signs make sure that even if the formula is copied it will always point to those fields), the2
tells the program to place the second value in the table as the result, and theFALSE
makes sure that only exact matches are used.Once the formula works for the first cell, copy it for the whole column and then, just as we did with the concatenation formula, copy the whole column and paste it again as values only.
Once this is done, delete the table that we added.
Finally, save your file as a
Windows Comma Separated (.csv)
file. If you are working with Google Sheets, download your file asComma-separated values
.
BK | Kings |
BX | Bronx |
K | Kings |
MN | New York |
NY | New York |
Q | Queens |
QN | Queens |
R | Richmond |
ST | Richmond |
Geocoding
Now, finally, we are ready to go to QGIS and start geocoding.
The first step is to open QGIS and download the MMQGIS plugin. To do this click on
Plugins
and selectManage and Install Plugins...
Once the list of plugins has been refreshed, look for the
MMQGIS
plugin and install it.Now, open a new map and add the
Boroughs
shapefile. This is not necessary but it will help us verify the results of the geocoding.Finally, open the geocoding window by clicking on
MMQGIS
and selectingGeocode
andGeocode CSV with Google/OpenStreetMap
Now select the file that we prepared as the input, and the appropriate fields for address, county, city, and state.
Leave the web service as
Google Maps
initially. If this one doesn't work, you can try theOpenStretMaps/Nominatim
.And set the
Output Shapefile
as well as theNot Found Output List
.Once you are ready click
OK
(and cross your fingers...). It will take a while because the plugin takes into account the limits of the API and delays the request accordingly. For our 300 or so requests it should take between 5 and 10 minutes.Once the geocoding process finishes you should have a new layer in your map with your geocoded points. This layer will still have all the data present in the base file. In addition, you should also have on your computer (wherever you placed it) a file with the records that were the service was unable to geocode.
Additional Options
In many cases you might need to geocode more than two or three hundred records. In these cases you should probably use your own Google Maps Geocoding API key. However, remember that even if you use your own key, Google still has a limit of 50 requests per minute and a total of 2,500 requests per day.
To obtain a key you should use a Google account to access the Google Developer Console. Once you sign in, you should go to the Google API Console (link at the bottom of the Google Developer Console page) and create a new project.
Once the project has been created, click on
Enable APIs and Services
, search for "geocoding" and once you find it, enable theGoogle Maps Geocoding API
for this project.Finally, return to your Google API project page and on the left hand panel click on
Credentials
. There, click onCreate credentials
and chooseAPI key
from the dropdown menu. This is the key you should add to the MMQGIS plugin menu when geocoding.


EpicPurpose:
Useful for visualizing all EPIC issues and how they span across
various components/modules within the application.
StoryPurpose:
Useful for visualizing a selected story in the context of other linked issues,
highlighting dependencies and overall associated feature delivery pipeline.


{# Copyright (c) 2015 The Pycroft Authors. See the AUTHORS file. This file is part of the Pycroft project and licensed under the terms of the Apache License, Version 2.0. See the LICENSE file for details. #} {%- import "macros/navigation.html" as navigation with context -%} {%- import "macros/resources.html" as resources with context -%}
{{ resources.link_css("libs/bootstrap/dist/css/bootstrap.min.css") }} {{ resources.link_css("libs/bootstrap-table/dist/bootstrap-table.min.css") }} {{ resources.link_css("libs/bootstrap-datepicker/css/datepicker3.css") }} {{ resources.link_css("libs/typeahead.js-bootstrap3.less/typeahead.css") }} {{ resources.link_css("style.css") }} {% block page_css %}{% endblock %}


Washedby the silvery waves of the Arabian Sea, the Venice of the East welcomes you to the backwaters of Kerala.
The Palm fringed canals and shores bustling with glimpses from the day to day life in the country side, the mirror still lagoons, picture book lakesides and its long sandy beach has blessed , the water locked district, to become one of the best Backwater tourism destinations in God's Own Country.
'Alappuzha' was formerly known as Alleppey and the Alleppey district was formed in the year 1957. Interestingly, it was in 1990, the destination changed its official name into Alappuzha. But still today, the name 'Alleppey' is popular among the tourists visiting the destination.
The large network of canals provides Alappuzha its lifeline. Water carnivals using the gigantic snake boats and the country canoes of varying sizes have an important role in the community life of the people of the district.


Test for management of check-box and radio-button inputs
Base
Baked Potato
Steamed Rice
Tortilla
Options
Beans
Butter
Cheese
Chilli Flakes
Onions
Sour Cream


XML (eXtensible Markup Language) is universal format to represent information. It is supported by all programming languages. It is mainly used to store and transport data.
Before putting data into XML, we need to define the schema for the XML. Schema is the template or skeleton of the XML.
XML template consists of tags/nodes/elements and attributes. Nodes can have subnodes. Attributes contains actual data. Top most element is called root element.
Collections are set of objects of class. XML essentially is a representation of this collection. Properties in a class can be either an element or attribute in XML. So, any object of a class can be pushed into XML. The process of converting class object into XML is serialization and reverse is deserialization
XML became common language for systems to communicate over web. Systems are developed in various languages like java or c# or python. However, when such system wants to communicate with others; XML is the standard language used. However, this involves serialization and deserialization of XML/Objects.


{% extends 'layout-email.html' %} {% set version = "emails" %} {% set bodyClasses = "app-email-body" %} {% set emailFrom =<EMAIL_ADDRESS>%} {% set emailTo =<EMAIL_ADDRESS>%} {% set emailSubject = "Thank you for registering your permission to take part in coronavirus clinical trials" %} {% block beforeMain %} {% endblock %} {% block content %}
Dear Joe Bloggs,
You have given your permission to be contacted for taking part in coronavirus vaccine research.
Researchers will contact you if they think you may be suitable for a clinical trial.
There is no guarantee you will be contacted to be part of a clinical trial. You may not be suitable for a trial even after researchers make contact.
You can find out more information about the different types of research studies and trials on the Be Part of Research website.
Find out how to withdraw your permission to be contacted for coronavirus vaccine trials.
{% endblock %}


| HOME | DOWNLOAD | DOCUMENTATION | FORUM | FAQ |
> Home > Documentation > Spherical Harmonic Transformations
MAKEGRID2D(1) SHTOOLS 2.6 MAKEGRID2D(1)
MakeGrid2D
MakeGrid2D - Create a 2D cylindrical map from a set of spherical harmonic coefficients.
SYNOPSIS
SUBROUTINE MakeGrid2D ( GRID, CILM, LMAX, INTERVAL, NLAT, NLONG, NORM, CSPHASE, F, A, NORTH, SOUTH, EAST, WEST ) REAL*8 GRID(180/INTERVAL+1, 360/INTERVAL+1), CILM(2, LMAX+1, LMAX+1), INTERVAL INTEGER LMAX, NLAT, NLONG INTEGER, OPTIONAL NORM, CSPHASE REAL*8, OPTIONAL F, A, NORTH, SOUTH, EAST, WEST
DESCRIPTION
MakeGrid2D will create a 2-dimensional cylindrical map, equally spaced in (geocentric) latitude and longitude, from a set of input spherical harmonic coefficients. The output grid is in raster format possessing upper-left and lower-right coordinates of (90 N, 0 E) and (90 S, 360 E), repsectively. If the optional parameters NORTH, SOUTH, EAST and WEST are specified, then the output grid will possess upper-left and lower-right coordinates of (NORTH, WEST) and (SOUTH, EAST), repsectively. The employed spherical harmonic normalization and Condon- Shortley phase convention can be set by the optional arguments NORM and CSPHASE; if not set, the default is to use geodesy 4-pi normalized harmonics that exclude the Condon-Shortley phase of (-1)^m. If the optional arguments F and A are specified, the output function will be referenced to an ellipsoid with flattening F and semimajor axis A.
ARGUMENTS
GRID (output) REAL*8, DIMENSION(180/INTERVAL+1, 360/INTERVAL+1) A 2D equally spaced map of the input spherical harmonic coefficients CILM. The array is in raster format with upper-left and lower-right coordinates of (90 N, 0 E) and (90 S, 360 E), respectively. CILM (input) REAL*8, DIMENSION (2, LMAX+1, LMAX+1) The real spherical harmonic coefficients to be expanded in the space domain. The coefficients C1lm and C2lm refer to the "cosine" (Clm) and "sine" (Slm) coefficients, respectively, with Clm = CILM(1, l+1, m+1) and Slm = CILM(2, l+1, m+1). Alternatively, C1lm and C2lm correspond to the positive and negative order coefficients, respectively. LMAX (input) INTEGER The maximum spherical harmonic degree of the coefficients CILM. INTERVAL (input) REAL*8 The latitudinal and longitudinal spacing of GRID. NLAT (output) INTEGER The number of latitudinal samples. Both 90 N and 90 S are included. NLONG (output) INTEGER The number of longitudinal samples. Both 0 and 360 E are included. NORM (input) INTEGER, OPTIONAL 1 (default) = Geodesy 4-pi normalized harmonics; 2 = Schmidt semi-normalized harmonics; 3 = unnormalized harmonics; 4 = orthonormal harmonics. CSPHASE (input) INTEGER, OPTIONAL 1 (default) = do not apply the Condon-Shortley phase factor to the associated Legendre functions; -1 = append the Condon-Shortley phase factor of (-1)^m to the associated Legendre functions. F (input) REAL*8, OPTIONAL The flattening of the reference ellipoid that is subtracted from the function. This is given by (R_equator - R_pole) / R_equator. The semi-major axis A (i.e., R_equator) must be specified for this calculation. A (input) REAL*8, OPTIONAL The semi-major axis of the reference ellispoid that is subtracted from the function. The flattening F must be specified for this calculation. NORTH (input) REAL*8, OPTIONAL The maximum latitude of the output raster grid, in degrees. The default is 90 degrees. SOUTH (input) REAL*8, OPTIONAL The minimum latitude of the output raster grid, in degrees. The default is -90 degrees. EAST (input) REAL*8, OPTIONAL The maximum longitude of the output raster grid, in degrees. The default is 360 degrees. WEST (input) REAL*8, OPTIONAL The minimum longitude of the output raster grid, in degrees. The default is 0 degrees.
SEE ALSO
shexpanddh(1), makegriddh(1), shexpandglq(1), makegridglq(1), makegravgrid2d(1), makemaggrid2d(1) <http://www.ipgp.jussieu.fr/~wieczor/SHTOOLS/SHTOOLS.html>
COPYRIGHT AND LICENSE
Copyright 2005-2007 by Mark Wieczorek<EMAIL_ADDRESS>This is free software; you can distribute and modify it under the terms of the revised BSD license. SHTOOLS 2.6 2009-08-18 MAKEGRID2D(1)
> Home > Documentation > Spherical Harmonic Transformations
| Centre National de la Recherche Scientifique | Institut de Physique du Globe de Paris | © 2011 Mark Wieczorek |


|
PDMGen3_RK
|
Class for using the hardware PDM (pulse-density modulation) audio decoder on nRF52 devices. More...
#include <PDMGen3_RK.h>
Public Types | |
| enum | OutputSize { OutputSize::UNSIGNED_8, OutputSize::SIGNED_16, OutputSize::RAW_SIGNED_16 } |
| Configuration for the size of the output data. More... | |
| enum | Range { Range::RANGE_128 = 0, Range::RANGE_256, Range::RANGE_512, Range::RANGE_1024, Range::RANGE_2048, Range::RANGE_4096, Range::RANGE_8192, Range::RANGE_16384, Range::RANGE_32768 } |
| Adjustment value so samples fill most of an 8 or 16 bit output size. More... | |
Public Member Functions | |
| PDMGen3 (pin_t clkPin, pin_t datPin, int16_t *samples, size_t samplesPerBuf) | |
| Allocate a PDMGen3 object for using the hardware PDM decoder. More... | |
| virtual | ~PDMGen3 () |
| Destructor. You typically allocate this as a global variable so it won't be deleted. | |
| nrfx_err_t | init () |
| Initialize the PDM module. More... | |
| void | uninit () |
| Uniniialize the PDM module. More... | |
| nrfx_err_t | start () |
| Start sampling. | |
| nrfx_err_t | stop () |
| Stop sampling. | |
| PDMGen3 & | withGainDb (float gainDb) |
| Sets the gain in dB. More... | |
| PDMGen3 & | withGain (nrf_pdm_gain_t gainL, nrf_pdm_gain_t gainR) |
| Sets the PDM gain using an rRF52 configuration value. More... | |
| PDMGen3 & | withStereoMode () |
| Set stereo mode. In stereo mode, each buffer will interleave L and R samples. Default is mono mode. | |
| PDMGen3 & | withMonoMode () |
| Set mono mode (left channel only). The default is mono mode, so you normally don't need to set this. More... | |
| PDMGen3 & | withMode (nrf_pdm_mode_t mode) |
| Sets a mode using a nrf_pdm_mode_t constant. Default is NRF_PDM_MODE_MONOl. More... | |
| PDMGen3 & | withFreq (nrf_pdm_freq_t freq) |
| Sets the sampling frequency. Default is 1.032 MHz, which works out to be a PCM sample rate of 16125 samples/sec. More... | |
| PDMGen3 & | withEdge (nrf_pdm_edge_t edge) |
| Sets the edge mode. More... | |
| PDMGen3 & | withOutputSize (OutputSize outputSize) |
| Sets the size of the output samples. More... | |
| PDMGen3 & | withRange (Range range) |
| Sets the range of the output samples. More... | |
| PDMGen3 & | withInterruptCallback (std::function< void(void *sampleBuf, size_t numSamples)> interruptCallback) |
| Sets a callback function to be called at interrupt time. | |
| void * | getAvailableSamples () const |
| Call this to poll for available samples from loop() More... | |
| void | doneWithSamples () |
| Call when you are done using the samples returns from getAvailableSamples(). Required! More... | |
| size_t | getSamplesPerBuf () const |
| Returns the number of samples (not bytes) that was returned from getAvailableSamples() | |
Protected Member Functions | |
| void | dataHandler (nrfx_pdm_evt_t const *const pEvent) |
| Used internally to handle notifications from the PDM peripheral. | |
Static Protected Member Functions | |
| static void | dataHandlerStatic (nrfx_pdm_evt_t const *const pEvent) |
| Used internally to handle notifications from the PDM peripheral (static function) More... | |
Protected Attributes | |
| pin_t | clkPin |
| The pin used for the PDM clock (output) | |
| pin_t | datPin |
| The pin used for the PDM data (input) | |
| int16_t * | samples |
| Buffer to hold samples. There are 2x samples per buf because of double buffering. | |
| size_t | samplesPerBuf |
| Number of samples per each of the double buffers. | |
| nrf_pdm_gain_t | gainL = NRF_PDM_GAIN_DEFAULT |
| 0x28 = 0dB gain | |
| nrf_pdm_gain_t | gainR = NRF_PDM_GAIN_DEFAULT |
| 0x28 = 0dB gain | |
| nrf_pdm_mode_t | mode = NRF_PDM_MODE_MONO |
| mono or stereo mode | |
| nrf_pdm_freq_t | freq = NRF_PDM_FREQ_1032K |
| clock frequency | |
| nrf_pdm_edge_t | edge = NRF_PDM_EDGE_LEFTFALLING |
| clock edge configuration | |
| OutputSize | outputSize = OutputSize::SIGNED_16 |
| Output size (8 or 16 bits) | |
| Range | range = Range::RANGE_2048 |
| Range adjustment factor. | |
| std::function< void(void *sampleBuf, size_t numSamples)> | interruptCallback = NULL |
| buffer completion callback | |
| bool | useBufferA = true |
| Which buffer we're reading from of the double buffers. | |
| int16_t * | availableSamples = NULL |
| Used to pass data to loop() for processing out of interrupt context. | |
Static Protected Attributes | |
| static PDMGen3 * | instance = NULL |
| Singleton instance of this class. More... | |
Class for using the hardware PDM (pulse-density modulation) audio decoder on nRF52 devices.
This only works on Gen 3 device (Argon, Boron, Xenon). Gen 2 devices include a STM32F205 MCU which does not include PDM support.
You typically create one PDMGen3 object as a global variable in your application.
|
strong |
|
strong |
Adjustment value so samples fill most of an 8 or 16 bit output size.
| PDMGen3::PDMGen3 | ( | pin_t | clkPin, |
| pin_t | datPin, | ||
| int16_t * | samples, | ||
| size_t | samplesPerBuf | ||
| ) |
Allocate a PDMGen3 object for using the hardware PDM decoder.
| clkPin | Clock pin. Use any available GPIO: A0, A1, ..., D0, D1, ... even pins like RX, TX, etc. if you are not using that interface. Will be set as OUTPUT. |
| datPin | Data pin. Use any available GPIO. Will be set as INPUT. |
| samples | Pointer to a buffer to hold samples. Note: This must be 2 * samplesPerBuf int16_t values, and the number of bytes used will be 4 * samplesPerBuf because they're 16-bit samples. |
| samplesPerBuf | The number of int16_t (signed 16-bit) samples in each of the double buffers. |
You may want to use the PDMGen3Static class instead which statically allocates the buffers on the heap at compile time, eliminating the need to manually manage them.
|
staticprotected |
Used internally to handle notifications from the PDM peripheral (static function)
As this relies on the singleton (instance), there can only be one instance of this class, however that's also the case because there is only one PDM peripheral on the nRF52.
|
inline |
Call when you are done using the samples returns from getAvailableSamples(). Required!
This allows the buffer to be reused. If you don't call this, data will be corrupted.
|
inline |
Call this to poll for available samples from loop()
Be sure to call doneWithSamples() if a non-NULL value is returned!
| nrfx_err_t PDMGen3::init | ( | ) |
Initialize the PDM module.
This is often done from setup(). You can defer it until you're ready to sample if desired, calling right before start().
| void PDMGen3::uninit | ( | ) |
Uniniialize the PDM module.
You normally will just initialize it once and only start and stop it as necessary, however you can completely uninitialize it if desired. The clkPin will be reset to INPUT mode.
|
inline |
Sets the edge mode.
| edge | Edge mode. Whether left or mono channel is sample on falling CLK (default) or rising CLK |
|
inline |
Sets the sampling frequency. Default is 1.032 MHz, which works out to be a PCM sample rate of 16125 samples/sec.
| freq | Sampling frequency: NRF_PDM_FREQ_1000K, NRF_PDM_FREQ_1032K (default), or NRF_PDM_FREQ_1067K |
|
inline |
Sets the PDM gain using an rRF52 configuration value.
| gainL | The nRF52 gain value for the left or mono channel |
| gainR | The nRF52 gain value for the right channel |
| PDMGen3 & PDMGen3::withGainDb | ( | float | gainDb | ) |
Sets the gain in dB.
| gainDb | Gain in dB, from -20 (minimum) to +20 (maximum) in 0.5 dB steps |
|
inline |
Sets a mode using a nrf_pdm_mode_t constant. Default is NRF_PDM_MODE_MONOl.
In mono mode, only the left channel is sampled, so every sample in the buffer will be from the left channel.
|
inline |
Set mono mode (left channel only). The default is mono mode, so you normally don't need to set this.
In mono mode, only the left channel is sampled, so every sample in the buffer will be from the left channel.
|
inline |
Sets the size of the output samples.
| outputSize | The output size enumeration |
Sets the range of the output samples.
| range | The range enumeration |
RANGE_128 From -128 to 127 (8 bits) RANGE_256 From -256 to 255 (9 bits) RANGE_512 From -512 to 511 (10 bits) RANGE_1024 From -1024 to 1023 (11 bits) RANGE_2048 From -2048 to 2047 (12 bits) (default) RANGE_4096 From -4096 to 4095 (13 bits) RANGE_8192 From -8192 to 8191 (14 bits) RANGE_16384 From -16384 to 16383 (15 bits) RANGE_32768 From -32768 to 32767 (16 bits) (same as raw mode)
|
staticprotected |
Singleton instance of this class.
Since there is only one PDM decoder on the nRF52 you must create only one instance of this class (typically as a global variable).


The Problem
Using CSS selectors in tests
- Selecting elements via CSS can be brittle. We are selecting elements based on something that could change.
- The purpose of CSS classes are styling, not testing.
Solution:ember-test-selectors
Tell me more...
- Use HTML5 data attributes for your elements
- Provides a testSelector function - you provide a data attribute and it returns the element
- Strips out the attributes on production builds (can override via the build file)
- Does some heavy lifting for data attributes and components for you, just pass a data test attribute and you're done
Example:
This test looks at a collection of usage charges and asserts
Template Changes:
Re-written Test:
0 dependencies on CSS classes!
Summary
- Less brittle tests, since they are no longer dependent on CSS classes
- Can be used with integration or acceptance tests
- Really easy to implement
- Great docs and resources online


About us
It is formed by a Venezuelan family, entrepreneurs, with human qualities and residing in
Barcelona, Spain, since 2003.
We are dedicated to fulfill and make a reality the dream of many Venezuelan homes that
we are outside of our mother country: Delight with traditional Venezuelan dishes, both
in person and at home..


Source code for dynaconf.loaders.vault_loader
# docker run -e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' -p 8200:8200 vault
# pip install hvac
from dynaconf.utils import build_env_list
from dynaconf.utils.parse_conf import parse_conf_data
try:
from hvac import Client
from hvac.exceptions import InvalidPath
except ImportError:
raise ImportError(
"vault package is not installed in your environment. "
"`pip install dynaconf[vault]` or disable the vault loader with "
"export VAULT_ENABLED_FOR_DYNACONF=false"
)
IDENTIFIER = "vault"
# backwards compatibility
_get_env_list = build_env_list
[docs]def get_client(obj):
client = Client(
**{k: v for k, v in obj.VAULT_FOR_DYNACONF.items() if v is not None}
)
if obj.VAULT_ROLE_ID_FOR_DYNACONF is not None:
client.auth_approle(
role_id=obj.VAULT_ROLE_ID_FOR_DYNACONF,
secret_id=obj.get("VAULT_SECRET_ID_FOR_DYNACONF"),
)
assert client.is_authenticated(), (
"Vault authentication error: is VAULT_TOKEN_FOR_DYNACONF or "
"VAULT_ROLE_ID_FOR_DYNACONF defined?"
)
return client
[docs]def load(obj, env=None, silent=None, key=None):
"""Reads and loads in to "settings" a single key or all keys from vault
:param obj: the settings instance
:param env: settings env default='DYNACONF'
:param silent: if errors should raise
:param key: if defined load a single key, else load all in env
:return: None
"""
client = get_client(obj)
env_list = build_env_list(obj, env)
for env in env_list:
path = "/".join([obj.VAULT_PATH_FOR_DYNACONF, env])
mount_point = obj.VAULT_MOUNT_POINT_FOR_DYNACONF
try:
data = client.secrets.kv.read_secret_version(
path, mount_point=mount_point
)
except InvalidPath:
# If the path doesn't exist, ignore it and set data to None
data = None
if data:
# There seems to be a data dict within a data dict,
# extract the inner data
data = data.get("data", {}).get("data", {})
try:
if data and key:
value = parse_conf_data(data.get(key), tomlfy=True)
if value:
obj.set(key, value)
elif data:
obj.update(data, loader_identifier=IDENTIFIER, tomlfy=True)
except Exception as e:
if silent:
return False
raise
[docs]def write(obj, data=None, **kwargs):
"""Write a value in to loader source
:param obj: settings object
:param data: vars to be stored
:param kwargs: vars to be stored
:return:
"""
if obj.VAULT_ENABLED_FOR_DYNACONF is False:
raise RuntimeError(
"Vault is not configured \n"
"export VAULT_ENABLED_FOR_DYNACONF=true\n"
"and configure the VAULT_FOR_DYNACONF_* variables"
)
data = data or {}
data.update(kwargs)
if not data:
raise AttributeError("Data must be provided")
client = get_client(obj)
path = "/".join([obj.VAULT_PATH_FOR_DYNACONF, obj.current_env.lower()])
mount_point = obj.VAULT_MOUNT_POINT_FOR_DYNACONF
client.secrets.kv.create_or_update_secret(
path, secret=data, mount_point=mount_point
)
load(obj)
[docs]def list_envs(obj, path=""):
"""
This function is a helper to get a list of all the existing envs in
the source of data, the use case is:
existing_envs = vault_loader.list_envs(settings)
for env in exiting_envs:
with settings.using_env(env): # switch to the env
# do something with a key of that env
:param obj: settings object
:param path: path to the vault secrets
:return: list containing all the keys at the given path
"""
client = get_client(obj)
path = path or obj.get("VAULT_PATH_FOR_DYNACONF")
try:
return client.list(f"/secret/metadata/{path}")["data"]["keys"]
except TypeError:
return []


{{ define "main" }}
I'm an Engineering Director for Pivotal Cloud Foundry in New York.
In this role I manage a team of about 70 engineers, provide technical leadership to about 10 product teams, and generally do my best to give away as many legos as possible.


Back in August, I started contributing to polars
, an exciting new dataframe library that is modern, memory-efficient, and lightning FAST (check out the benchmarks here). It is under active development so bugs are identified (and resolved) at an incredible pace. One morning, I noticed a user reporting an error with the exponentially-weighted variance computation – the polars
result differed significantly from what pandas
produced. Intrigued, I began looking for the source of the disparity.
The diagnosis
I first replicated the user’s issue on my own machine
>>> pl.Series([1., 2., 3.]).ewm_var(alpha=0.5, adjust=False)
shape: (3,)
Series: '' [f64]
[
0.0
0.25
0.6875
]
>>> pd.Series([1., 2., 3.]).ewm(alpha=0.5, adjust=False).var()
0 NaN
1 0.5
2 1.1
dtype: float64
Looking closer at the polars
and pandas
function signatures, I noticed a bias
parameter was notably absent from the polars
implemenation (ignore the adjust
parameter for now, we will get to that shortly). And indeed, this was the problem!
>>> pd.Series([1., 2., 3.]).ewm(alpha=0.5, adjust=False).var(bias=False)
0 NaN
1 0.5
2 1.1
dtype: float64
>>> pd.Series([1., 2., 3.]).ewm(alpha=0.5, adjust=False).var(bias=True)
0 0.0000
1 0.2500
2 0.6875
dtype: float64
With adjust=False
, polars
apparently computed a biased variance by default, whereas pandas
returned an unbiased estimator. But the adjust
parameter proved to be significant too. When adjust=True
, the polars
results were entirely incorrect.
>>> pl.Series([1., 2., 3.]).ewm_var(alpha=0.5, adjust=True)
shape: (3,)
Series: '' [f64]
[
0.0
0.25
0.569444
]
>>> pd.Series([1., 2., 3.]).ewm(alpha=0.5, adjust=True).var(bias=False)
0 NaN
1 0.500000
2 0.928571
dtype: float64
>>> pd.Series([1., 2., 3.]).ewm(alpha=0.5, adjust=True).var(bias=True)
0 0.000000
1 0.222222
2 0.530612
dtype: float64
Clearly this needed to be fixed, but implementing a correct variance algorithm would first require a foray in the mathematics of exponential weights.
Exponentially-weighted mean
Given data points \(x_i\) and weights \(w_i\) for \(i \in \{0, 1, \dots, n\}\), the general formula for a weighted mean \(\mu\) is given by
\[\mu := \frac{\sum_0^n w_i x_i}{\sum_0^n w_i}\]If the data points are ordered (in time, perhaps) we might want to compute the weighted mean over an expanding window. With some additional notation, we can identify a \(\mu_j\) at each observation \(x_j : j \in \{0, 1, \dots, n\}\), where \(\mu_j\) is the weighted mean of all prior observations \(x_{i \leq j}\). As our window expands, and more data points are considered, the weight corresponding to a particular \(x_i\) will vary, so it is wise to index the weights by \((j)\) as well.
\[\mu_j := \frac{\sum_{i=0}^j w^{(j)}_i x_i}{\sum_{i=0}^j w^{(j)}_i} = \frac{\sum_{i=0}^j w^{(j)}_i x_i}{W_j}\]where I’ve defined \(W_j := \sum_i w_i^{(j)}\).
But naively computing a \(j\)-term sum at each step is far too costly. Instead, I will derive a recurrence relation that allows us to compute \(\mu_j\) in an online fashion. From the definition of \(\mu_j\), it is readily apparent that
\[W_{j + 1} \mu_{j + 1} = \sum_{i=0}^{j + 1} w_i^{(j + 1)} x_i = \sum_{i=0}^{j} w_i^{(j + 1)} x_i + w_{j + 1}^{(j + 1)} x_{j + 1}\] \[\implies \mu_{j + 1} = \frac{1}{W_{j + 1}} \left[ \sum_{i=0}^{j} w_i^{(j + 1)} x_i + w_{j + 1}^{(j + 1)} x_{j + 1} \right]\]At this point, though, we lack a crucial relationship between \(w_i^{(j + 1)}\) and \(w_i^{(j)}\) that must be resolved.
It is important to note that until now, I’ve discussed an arbitrary weighting scheme, ie. I have not yet used any properties of the weights themselves, but I will now restrict my analysis to an exponential weighting scheme with parameter \(\alpha \in (0, 1)\).
The unadjusted case
The standard exponentially-weighted mean formula is given by the pair of equations
\[\mu_0 = x_0 \\ \mu_j = (1 - \alpha) \mu_{j - 1} + \alpha x_j\]which, when expanded out, yield
\[\mu_0 = x_0 \\ \mu_j = (1 - \alpha)^j x_0 + \alpha \sum_{i = 1}^j (1 - \alpha)^{j - i} x_i\]for finite \(j\). This equation has a remarkable property, namely the weights sum to \(1\) for all \(j\).
\[W_j = (1 - \alpha)^j + \alpha \sum_{i = 1}^j (1 - \alpha)^{j - i} = 1\]This weighting scheme is what we will call the “unadjusted” exponential weightings.
The adjusted case
There is another way to specify the weights in an exponentially-weighted mean. Starting with the definition
\[\mu_j = (1 - \alpha) \mu_{j - 1} + \alpha x_j\]we can write
\[\mu_j = \alpha x_j + \alpha (1 - \alpha) x_{j-1} + \alpha (1-\alpha)^2x_{j - 2} + \dots\]Assuming an infinite number of data points, the general form of the weights is
\[w_i^{(j)} = \alpha (1 - \alpha)^{j - i}\]However, note that
\[W_j = \sum_{i=0}^j w_i^{(j)} = \alpha \sum_{i=0}^j (1 - \alpha)^{j - i} < 1\]Since our weights no longer sum to \(1\), we must normalize the weights and divide by \(W_j\)
\[\mu_j = \frac{\alpha}{W_j} \sum_{i=0}^j (1 - \alpha)^{j-i} x_i = \frac{x_j + (1 - \alpha) x_{j-1} + \dots + (1 - \alpha)^{j} x_0}{1 + (1 - \alpha) + \dots + (1 - \alpha)^{j}}\]When computed this way, \(\mu_j\) is called the “adjusted” exponentially-weighted mean.
An incremental update
With these defintions in hand, we can again consider the equation
\[\mu_{j + 1} = \frac{1}{W_{j + 1}} \left[ \sum_{i=0}^{j} w_i^{(j + 1)} x_i + w_{j + 1}^{(j + 1)} x_{j + 1} \right]\]I have shown that for both adjusted and unadjusted variants
\[w_{i}^{(j + 1)} = (1 - \alpha) w_{i}^{(j)} : i \leq j\]and for \(i = j + 1\),
\[w_{j+1}^{(j+1)} = \begin{cases} \alpha & \leftarrow\mathrm{unadjusted} \\ 1 & \leftarrow \mathrm{adjusted} \\ \end{cases}\]\(W_{j + 1}\) is easily computed by the recurrence
\[W_{j + 1} = \sum_{i=0}^j w_i^{j+1} + w_{j + 1}^{(j + 1)} = (1 - \alpha) W_{j} + w_{j + 1}^{(j + 1)}\](although it is worth reminding the reader that in the unadjusted case this computation is strictly unnecessary as the weights always sum to \(1\)). Lastly, I note an important identity
\[\sum_{i = 0}^j w_i^{(j + 1)} x_i =\left( W_{j + 1} - w_{j + 1}^{(j + 1)} \right) \mu_j\]Putting the various pieces together and working through the algebra, I am now able to write down the one-step recurrence relation
\[\mu_{j + 1} = \frac{w_{j + 1}^{(j+1)}}{W_{j+1}} \left( x_{j + 1} - \mu_j \right) + \mu_j\]Exponentially-weighted variance
With a firm understanding of the mathematics underlying the exponentially-weighted mean, we are now ready to analyze the exponentially-weighted variance.
The general formula for a weighted variance \(\sigma^2\) is given by
\[\sigma^2 := \frac{1}{W_n} \sum_{i=0}^n w_i \left( x_i - \mu \right)^2\]as we did with the mean, we can compute a weighted variance at each \(j \in \{0, 1, \dots, n\}\) by
\[\sigma_j^2 := \frac{1}{W_j} \sum_{i=0}^j w_i^{(j)} \left( x_i - \mu_j \right)^2\]An incremental update
To design an efficient algorithm for computing \(\sigma_j^2\), I start with some useful, easily derived, identities
\[x_i - \mu_j = ( x_i - \mu_{j - 1} ) - \frac{w_j^{(j)}}{W_j} \left( x_j - \mu_{j-1} \right)\]which for \(i = j\) can be written
\[x_j - \mu_j = \frac{W_j - w_j^j}{W_j} \left( x_j - \mu_{j-1} \right)\]We are thus interested in solving
\[\sigma_j^2 = \frac{1}{W_j} \underbrace{\sum_{i=0}^{j-1} w_i^{(j)} \left[ ( x_i - \mu_{j - 1} ) - \frac{w_j^{(j)}}{W_j} \left( x_j - \mu_{j-1} \right) \right]^2}_{X} + \frac{ w_j^{(j)} }{W_j} \left[ \frac{W_j - w_j^j}{W_j} \left( x_j - \mu_{j-1} \right) \right]^2\]The section I’ve identified as \(X\) can be expressed as
\[X = \sum_{i=0}^{j-1}w_i^{(j)} \left[ \left( x_i - \mu_{j-1} \right)^2 - 2 \frac{w_j^{(j)}}{W_j} \left( x_i - \mu_{j-1} \right) \left( x_j - \mu_{j - 1} \right) + \left( \frac{w_j^{(j)}}{W_j} \right)^2 \left( x_j - \mu_{j-1} \right)^2 \right]\]If you consider each of these terms separately, you will find
\[\sum_{i=0}^{j-1} w_i^{(j)} \left( x_i - \mu_{j - 1} \right)^2 = \left( W_j - w_j^{(j)} \right) \sigma_{j-1}^2\] \[\sum_{i=0}^{j-1} w_i^{(j)} \frac{w_j^{(x)}}{W_j} \left( x_i - \mu_{j-1} \right) \left( x_j - \mu_{j-1} \right) = 0\] \[\sum_{i=0}^{j-1} w_i^{(j)} \left( \frac{w_j^{(j)}}{W_j} \right)^2 \left( x_j - \mu_{j-1} \right)^2 = \left( \frac{w_j^{(j)}}{W_j} \right)^2 \left( x_j - \mu_{j-1} \right)^2 \left( W_j - w_j^{(j)} \right)\]which, after some simplification, implies
\[\sigma_j^2 = \left( 1 - \frac{w_j^{(j)}}{W_j} \right) \left[ \sigma_{j-1}^2 + \frac{w_j^{(j)}}{W_j} \left( x_j - \mu_{j-1} \right)^2 \right]\]This is hugely important – it means at each step \(j\) we don’t have to traverse all prior observations to compute \((x_i - \mu_j)^2\). It therefore suggests an \(O(n)\) algorithm is possible.
Biased-ness
If we pause to realize that \(\sigma_j^2\) is only a sample estimate for the population parameter \(\sigma^2\), we can formalize the relationship between \(\sigma_j^2\) and \(\sigma^2\). If we define
\[\theta_j = \sum_{i=0}^{j} \left[ w_i^{(j)} \right]^2\]we can then compute
\[\mathbf{E} [ \sigma_j^2 ] = \frac{1}{W_j} \sum_{i=0}^j w_i^{(j)} \left( \mathbf{E} \left[ \left( x_i - \mu_j \right)^2 \right] \right) = \left( 1 - \frac{\theta_j}{W_j^2} \right) \sigma^2\]To derive this, it is useful to note that
\[\mathbf{E}[ x_i^2 ] = \mu^2 + \sigma^2 \\ \mathbf{E}[ x_i \mu_j ] = \mu^2 + \frac{\sigma^2}{W_j} w_i^{(j)} \\ \mathbf{E}[ \mu_j^2 ] = \mu^2 + \frac{\sigma^2 \theta_j}{W_j^2}\] \[\implies \mathbf{E} \left[ \left( x_i - \mu_j \right)^2 \right] = \sigma^2 - 2 \frac{w_i^{(j)}}{W_j} \sigma^2 + \frac{\theta_j}{W_j^2} \sigma^2\]In order to produce an unbiased estimate of \(\sigma^2\), we must therefore multiply our estimate by a bias correction term. In particular, we must compute
\[\left( 1 - \frac{\theta_j}{W_j^2} \right)^{-1} \sigma_j^2\]A practical mean/variance algorithm
I now present the algorithm in its entirety:
def exponentially_weighted(
xs: list[float], alpha: float, adjust: bool, bias: bool
) -> dict[str, list[float]]:
"""Compute and return the exponentially-weighted (mean, variance)."""
assert 0 < alpha < 1
if adjust:
wgt, wgt_sum, wgt_sum_sqr = 1, 0, 0
else:
# NOTE: we must ensure that `wgt_sum` and `wgt_sum_sqr` are
# equal to one in the first iteration
wgt, wgt_sum, wgt_sum_sqr = alpha, 1, (1 + alpha) / (1 - alpha)
result = {"mean": [], "var": []}
mean = xs[0]
var = 0
for i, x in enumerate(xs):
wgt_sum = (1 - alpha) * wgt_sum + wgt
wgt_sum_sqr = (1 - alpha) ** 2 * wgt_sum_sqr + wgt ** 2
diff = x - mean
ratio = wgt / wgt_sum
mean = mean + diff * ratio
var = (1 - ratio) * (var + ratio * diff ** 2)
# NOTE: the `i == 0` condition prevents a ZeroDivisionError
if bias or i == 0:
bias_correction = 1
else:
bias_correction = 1 - wgt_sum_sqr / (wgt_sum ** 2)
result["mean"].append(mean)
result["var"].append(var / bias_correction)
return result
Note that both polars
and pandas
provide options for dealing with missing values; this simple implementation puts that issue aside. For a more robust Rust implementation, see my merge request here.
References
-
Welford, B. P. “Note on a Method for Calculating Corrected Sums of Squares and Products.” Technometrics, vol. 4, no. 3, 1962, pp. 419–20. JSTOR, https://doi.org/10.2307/1266577. Accessed 31 Aug. 2022.
-
Hunter, J. S. (1986). The Exponentially Weighted Moving Average. Journal of Quality Technology, 18(4), 203–210. https://doi.org/10.1080/00224065.1986.11979014
-
Wikipedia contributors. (2022, September 2). Weighted arithmetic mean. In Wikipedia, The Free Encyclopedia. Retrieved 00:40, September 4, 2022, from https://en.wikipedia.org/w/index.php?title=Weighted_arithmetic_mean&oldid=1108027383


|
Ext.NET
5.3.0
.NET Component Framework for Enterprise Level Apps
|
Public Member Functions | |
| Builder (TButtonGroup component) | |
| virtual TBuilder | Columns (int columns) |
| The columns configuration property passed to the configured layout manager. See Ext.layout.TableLayout.columns. More... | |
| Builder () | |
| Builder (ButtonGroup component) | |
| Builder (ButtonGroup.Config config) | |
| Public Member Functions inherited from Ext.Net.Panel.Builder< TButtonGroup, TBuilder > | |
| Builder (TPanel component) | |
| Builder () | |
| Builder (Panel component) | |
| Builder (Panel.Config config) | |
| virtual TBuilder | Listeners (Action< PanelListeners > action) |
| Client-side JavaScript Event Handlers More... | |
| virtual TBuilder | DirectEvents (Action< PanelDirectEvents > action) |
| Server-side Ajax Event Handlers More... | |
Static Public Member Functions | |
| static implicit | operator Builder (ButtonGroup component) |
| Static Public Member Functions inherited from Ext.Net.Panel.Builder< TButtonGroup, TBuilder > | |
| static implicit | operator Builder (Panel component) |
| TButtonGroup | : | ButtonGroup | |
| TBuilder | : | Builder | |
| TBuilder | : | TButtonGroup | |
| TBuilder | : | TBuilder |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
The columns configuration property passed to the configured layout manager. See Ext.layout.TableLayout.columns.
|
inlinestatic |


{% extends 'bookclub/base.html' %} {% block title %} All the books {% endblock %}} {% block content %}
What were your thoughts on the latest book?
{{previous_books.0.description|truncatewords:150}}
See the discussion{{ upcoming_book.description }}
{% endfor %}{{ previous_book.description }}
{% endfor %}


I ordered 25g of this stuff from a web site after hearing about its mind altering effects. I put the root in my coffee grinder and got a fine powder. I boiled this powder with water for about 30 minutes and got a kind of tea. I drank the tea (Tasted nasty) and ate the root that was left at the bottom (I had to force it down and use a chaser) and sat around waiting for the effects to kick in.
After about 30 minutes i felt kinda wierd, sort of disconected. This lasted for about another 2 hours until I threw up. As unpleasent as it was swallowing the root, it was 100 times worse on the way up! I continued to puke every 15 minutes or so for the next 4 hours or more! In between vomiting i would drink water and assume the fetal position on the floor of the bathroom shivering with fever like sympoms. I finaly passed out in the early morning. I am currently on Paxil, Webutrin, and Buspar for depression and anxiety. I know that I'm not supposed to take these medications with a MAOI. I read somewhere about the effects of some people who took a Ayahuasca concotion who were on certain anti-depressant medications. Maybe this adverse reaction people are experiencing is a result of a MAOI present in the Calamus root. I wonder if anyone knows.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


 I have interest in software development, web development, IoT implementation, Robotics, Mechatronics and startup ecosystem.  I consider my life as a playground to test my imaginations. I have no regrets and I am ready to try something new and rather fail then not trying at all. I am Passionate about Photography. I love to play with my camera. I consider photography as an art.
Jacobs University Bremen
College Ring 2, Bremen 28759
Germany
+49 1702 765 414


Carlos Lantigua
Specializing in
UI / UX Design, Conversion Rate Optimization, Visual Design and Information Architecture, database Architecture, Responsive Mobile and Desktop Applications
- HTML5
- CSS4
- JavaScript
- AngularJS
- JQuery


updatez¶
Update arrays in a single file in numpy’s npz format
This module was written by Matthias Cuntz while at Institut National de Recherche pour l’Agriculture, l’Alimentation et l’Environnement (INRAE), Nancy, France.
- copyright:
Copyright 2023- Matthias Cuntz, see AUTHORS.rst for details.
- license:
MIT License, see LICENSE for details.
The following functions are provided:
|
Update arrays in a single file in uncompressed |
|
Update arrays in a single file in compressed |
- History
Written Jan 2023 by Matthias Cuntz (mc (at) macu (dot) de)
- updatez(file, *args, **kwds)[source]¶
Update arrays in a single file in uncompressed
.npz
format.Provide arrays as keyword arguments to store them under the corresponding name in the output file:
updatez(fn, x=x, y=y)
.If arrays are specified as positional arguments, i.e.,
updatez(fn, x, y)
, their names will be arr_0, arr_1, etc.If arrays do not exist yet in the npz-file, they will be appended. Existing arrays with the same name will be replaced by the new arrays.
If
file
does not exist yet,updatez
is a simple wrapper tonumpy.savez
.- Parameters:
file (str) – Filename where the data will be saved. The
.npz
extension will be appended to the filename if it is not already there.args (Arguments, optional) – Arrays to save to the file. Please use keyword arguments (see kwds below) to assign names to arrays. Arrays specified as args will be named “arr_0”, “arr_1”, and so on.
kwds (Keyword arguments, optional) – Arrays to save to the file. Each array will be saved to the output file with its corresponding keyword name.
- Return type:
None
See also
numpy.savez
Save several arrays into an uncompressed
.npz
archivenumpy.savez_compressed
Save arrays into a compressed
.npz
archivepyjams.updatez_compressed
Update arrays in a compressed
.npz
archivenumpy.load
Load the files created by updatez.
Notes
The
.npz
file format is a zipped archive of files named after the variables they contain. The archive is not compressed and each file in the archive contains one variable in.npy
format. For a description of the.npy
format, seenumpy.lib.format
.When opening the saved
.npz
file with load a NpzFile object is returned. This is a dictionary-like object which can be queried for its list of arrays (with the.files
attribute), and for the arrays themselves.Keys passed in kwds are used as filenames inside the ZIP archive. Therefore, keys should be valid filenames; e.g., avoid keys that begin with
/
or contain.
.When naming variables with keyword arguments, it is not possible to name a variable
file
as this would cause the argumentfile
to be defined twice in the call toupdatez
.Contrary to
numpy.savez
,updatez
allows only filenames and not file-like or path-like objects.Examples
>>> import os >>> from tempfile import mkstemp >>> import numpy as np >>> fd, outfile = mkstemp('.npz') >>> os.close(fd) >>> x = np.arange(10) >>> y = np.sin(x) >>> xnew = np.arange(15) >>> ynew = np.sin(xnew)
Using numpy.savez with *args, the arrays are saved with default names.
>>> np.savez(outfile, x, y) >>> npzfile = np.load(outfile) >>> npzfile.files ['arr_0', 'arr_1'] >>> npzfile['arr_0'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Using updatez with *args, the arrays with default names will be overwritten.
>>> npzfile.close() >>> updatez(outfile, xnew, ynew) >>> npzfile = np.load(outfile) >>> npzfile.files ['arr_0', 'arr_1'] >>> npzfile['arr_0'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
Using updatez with **kwds, the arrays are saved with the keyword names.
>>> npzfile.close() >>> updatez(outfile, x=x, xnew=xnew) >>> npzfile = np.load(outfile) >>> sorted(npzfile.files) ['arr_0', 'arr_1', 'x', 'xnew'] >>> npzfile['x'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> npzfile['xnew'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
Clean up.
>>> npzfile.close() >>> os.remove(outfile)
- updatez_compressed(file, *args, **kwds)[source]¶
Update arrays in a single file in compressed
.npz
format.Provide arrays as keyword arguments to store them under the corresponding name in the output file:
updatez_compressed(fn, x=x, y=y)
.If arrays are specified as positional arguments, i.e.,
updatez_compressed(fn, x, y)
, their names will be arr_0, arr_1, etc.If arrays do not exist yet in the npz-file, they will be appended. Existing arrays with the same name will be replaced by the new arrays.
If
file
does not exist yet,updatez_compressed
is a simple wrapper tonumpy.savez_compressed
.- Parameters:
file (str) – Filename where the data will be saved. The
.npz
extension will be appended to the filename if it is not already there.args (Arguments, optional) – Arrays to save to the file. Please use keyword arguments (see kwds below) to assign names to arrays. Arrays specified as args will be named “arr_0”, “arr_1”, and so on.
kwds (Keyword arguments, optional) – Arrays to save to the file. Each array will be saved to the output file with its corresponding keyword name.
- Return type:
None
See also
numpy.savez
Save arrays into an uncompressed
.npz
file formatnumpy.savez_compressed
Save arrays into a compressed
.npz
file formatpyjams.updatez
Update arrays in uncompressed
.npz
file formatnumpy.load
Load the files created by updatez_compressed.
Notes
The
.npz
file format is a zipped archive of files named after the variables they contain. The archive is compressed withzipfile.ZIP_DEFLATED
and each file in the archive contains one variable in.npy
format. For a description of the.npy
format, seenumpy.lib.format
.When opening the saved
.npz
file with load a NpzFile object is returned. This is a dictionary-like object which can be queried for its list of arrays (with the.files
attribute), and for the arrays themselves.Keys passed in kwds are used as filenames inside the ZIP archive. Therefore, keys should be valid filenames; e.g., avoid keys that begin with
/
or contain.
.When naming variables with keyword arguments, it is not possible to name a variable
file
as this would cause the argumentfile
to be defined twice in the call toupdatez_compressed
.Contrary to
numpy.savez_compressed
,updatez_compressed
allows only filenames and not file-like or path-like objects.Examples
>>> import os >>> from tempfile import mkstemp >>> import numpy as np >>> fd, outfile = mkstemp('.npz') >>> os.close(fd) >>> x = np.arange(10) >>> y = np.sin(x) >>> xnew = np.arange(15) >>> ynew = np.sin(xnew)
Using numpy.savez_compressed with *args, the arrays are saved with default names.
>>> np.savez_compressed(outfile, x, y) >>> npzfile = np.load(outfile) >>> npzfile.files ['arr_0', 'arr_1'] >>> npzfile['arr_0'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
Using updatez_compressed with *args, the arrays with default names will be overwritten.
>>> npzfile.close() >>> updatez_compressed(outfile, xnew, ynew) >>> npzfile = np.load(outfile) >>> npzfile.files ['arr_0', 'arr_1'] >>> npzfile['arr_0'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
Using updatez_compressed with **kwds, the arrays are saved with the keyword names.
>>> npzfile.close() >>> updatez_compressed(outfile, x=x, xnew=xnew) >>> npzfile = np.load(outfile) >>> sorted(npzfile.files) ['arr_0', 'arr_1', 'x', 'xnew'] >>> npzfile['x'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> npzfile['xnew'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
Clean up.
>>> npzfile.close() >>> os.remove(outfile)


These 9 displays are each running
Google Chrome
.
The Aquarium is written in 100%
HTML5
,
JavaScript
and
WebGL
.
The machines are kept in sync using
WebSockets
and a server
also written in
JavaScript
in
node.js
using
socket.io
.
Reset
Change View
Lasers
250 Fish
1000 Fish