changing the price of an exchange (in ecoinvent) with brightway? - brightway

I want to add a new exchange (by-product) to an existing activity that for which I would need to add a price property, in order to have the possibility of having an economic allocation between the reference product and the by-product.
I looked at the attributes of the exchanges with
exc.as_dict()
but this is not a field I could find anywhere.
Is it possible to alter the price of an exchange in the ecoinvent database with brightway2? (in order to have impact the economic allocation)

Prices have been available as exchange properties as of 33d9d67, released in 0.8.1 on February 25, 2021:
>>> import bw2data as bd
>>> a = bd.Database("ecoinvent 3.7.1 cutoff").random()
>>> for exc in a.technosphere():
>>> print(exc['properties'])['price']
{
'amount': 0.014,
'unit': 'EUR2005',
'comment': 'Calculated value based on data from United Nations Commodity Trade Statistics Database (comtrade.un.org). UN comtrade category: 252100 Limestone materials for manufacture of lime or cement. Year 2005. Using exchange rate of 1EURO = 1.209 USD. Average of price of import into 5 main markets (EU, US, JP, IN and CN).'
}
Be sure to save the exchange object afterwards if you want you changes to persist.
However, the answer of Nabla is correct, changing the price won't change the allocation. The multifunctional library wants to work on this, but it isn't simple. For example, there are many economic allocation methods in ecoinvent.
Luckily, allocation is not that difficult. I would recommend using helper functions from wurst (e.g. finding and copying exchanges). And implementing allocation is a good first exercise to learning how to use Brightway on a deeper level.

As far as I am aware price data is not yet parsed from the ecospold files. Brightway uses the version of ecoinvent after multifunctionality has been solved (by ecoinvent). So:
the prices are not yet there.
the algorithms to recalculate ecoinvent changing the prices aren't there either. The Ocelot project was an attempt but its not easy.
You may want to have a look to https://github.com/brightway-lca/multifunctional

Related

Azure search solr index definition for supporting multiple markets

I am building a product catalog for an e-comm website. I am having a requirement to build a azure search/solr/elastic search based index. The problem is saving the market specific attributes. The website is supporting 109 markets and there is each market specific data like ratings, price, views, wish-listed, etc. that I need to save in the index eg: Product1 will have 109 ratings(rating is different in each market)/109 prices(price might be different in each market) corresponding to 109 markets. Also I will have to use this attributes to add a boosting function so that when people are searching for this, products with higher view/ratings surfaces up. How do I design the index definition to support this? Can I achieve this by 1 index doc per product or do I have to create 1 index doc per market? Some pointers will be very helpful. I have spent couple of days on this and could not reach to a conclusion that is optimized for this use case. Thank you!
My proposed index definition:
-id
-mktUSA
--mktId
--rating
--views
--price
...
-mktCanada
--mktId
--rating
--views
--price
...
-locales
--En
--Fr
--Zh
...
...other properties
The problem with this approach is configuring a magnitude scoring functions inside scoring profile, to boost products based on the market
Say eg: If user is from Canada, only the Canada based rating/views should be considered and not the other market ratings while Cognitive search is calculating the search relevance score.
Is there any possible work around this? Elastic search has a neat solution of Function score query that can be used to configure the scoring function dynamically
From what I understand, your problem is that you want to have a single index with products that support 109 different markets. Many different properties for your Product model can then be market-specific. Your concern is that the model gets to big, or if it's a scalable design. It is. You can have 1000+ properties without a problem.
I have built a similar search solution for e-commerce for multiple markets.
For price, I specify one price per market. I have about 80 or so markets, so that's 80 prices. There is no way around it. I would probably do the same for ratings and views too. One per market.
In our application we use separate dimensions for market, language and country. A market can be Scandinavia, BeNeLux or Asia-Pacific. You need to clearly define what a market is in your case, and agree with the business which markets you have and how you handle changes. Countries can map directly to markets, but it may also differ. Finally, language is usually shared across markets/countries and you usually only have to support 20-25 languages.
Suggested data model
Id
TitleEnGb
TitleDeDe
TitleFrFr
...
PriceGb
PriceUs
PriceNo
PriceDe
...
RatingsGb
RatingsUs
RatingsNo
RatingsDe
...
DescriptionEnGb
DescriptionDeDe
DescriptionFrFr
...
I try to illustrate that the Title and Description are language-specific. The price and ratings are market-specific.
For the 20-25 language-specific properties, you have to think about what analyzers to use. You want to use language-specific analyzers, and preferably the Microsoft analyzers since they have much better linguistics support with full lemmatization and so on.
When you develop your frontend application you have to keep track of which market, country and language you then refer to the specific properties. This is the easiest way to support boosting and so on.
Per-market index is not recommended
You could create one index per market. I have gone down this route before. I would not recommend this. This means you have to update 109 indexes every time you add, change or delete an item. And Azure Search supports 50 indexes per service at the most anyways.

is there API for past NOAA weather forecasts (forecast archive)?

I'm looking for a source for old weather forecasts--yesterdays, last months, last years. For major cities in US.
Seems like it's easy to find future forecasts, and historical actual data, but not historical forecasts.
The product you're probably looking for is the National Digital Forecast Database, the gridded system the NWS uses to input most of its forecast. There's no API that I know of, but there are archived data files in places like here. This NWS page on degrib also offers some potential hints on what you may need.
The NWS does still also issue some specific point forecasts for certain locations, specialized forecasts for events like fires, plus forecast discussions, warning text, etc. If those are the types of things you are looking for, it may be a bit more of a slog to dig through and piece together find the product identifiers and archive resources you want. Iowa State offers a tool for accessing some of the past data, but only by office. You also may want to dig into some of the text products on their MTArchive site, particularly perhaps the Public files - the specific data is less organized, yet the simple layout may make it more straightforward to find what you need. This StormTrack thread may offer one final rabbit trail towards finding archives of NWS text products.
As mentioned in comments, you may also find there are additional users with useful input on the Earth Science Stack Exchange Beta community.

Data To Munge: Stock Trading, Exchange Trading

I know that a lot of this information is probably entirely privatized, but does anyone know of a good source of real time information on what kind of trading activity is where in the market? It doesn't need to be fast enough to actually make informed trading decisions based on it, I'm more looking to aggregate it into some beautiful graphics. For fun. Because I have personal problems.
I'd be grateful for any help!
The best I'm aware of is the Yahoo Finance API. It'll give you delayed prices and some bid/ask stuff. There's a description of how it works here:
http://www.gummy-stuff.org/Yahoo-data.htm
Not sure, but I was of the opinion that Google Finance API was better than Yahoo:
http://code.google.com/apis/finance/
There was a project called OpenTick that planned on giving access to data from the exchanges themselves (eg., the Chicago Board of Trade), provided you paid the exchanges whatever fees were required. That project quietly died.
You can get some market benchmark data from the St Louis Fed. Aside from that, I haven't found anything better than Yahoo! Finance or Google Finance. Both the NASD and the NYSE give access to historical data on their websites, but I don't see any kind of web service interface.
Bloomberg open api http://www.openbloomberg.com/open-api/ which is recently made free can be used to get historical market data and also real time data. If you are looking for historical stock price there is a nice api http://www.quandl.com/ , you can get even more then 10 year old stock prices for co. in many formats.
I would have subscribed to the suggestion of the Google API, but it is not available anymore.
This post offers the best list of Financial Data accessible from R I've encountered online: http://www.r-bloggers.com/financial-data-accessible-from-r-part-iv/.
Yet this is not an R post. Beyond those sources, I would wholeheartedly recommend TD Ameritrade's Thinkorswim platform (www.thinkorswim.com). It is a trading platform with free real time data to US financial markets. You can open an account and keep just one cent on it if not needed for actual investing/trading.
Furthermore, I would recommend the Ninja Trader platform (http://ninjatrader.com), which offers free end of day historical data for US financial markets. You can export data from Ninja Trader to txt format and then import it into R or Python if so desired.

How to compare data between a database and a guide which are differently structured?

A rather complicated problem in data exchange between a database and a bookform:
The organisation in which I work has a database in mysql for all social profit organisations in Brussels, Belgium. At the same time there is a booklet created in Indesign which was developed in a different time and with different people than the database and consequently has a different structure.
Every year a new book is published and the data needs to be compared manually because of this difference in structure. The book changes its way of displaying entries according to the need of a chapter. It would help to have a crossplatform search and change tool, best not with one keyword but with all the relevant data for an entry in the book.
An example of an entry in the booklet:
BESCHUTTE WERKPLAATS BOUCHOUT
Neromstraat 26 • 1861 Wolvertem • Tel 02-272 42 80 • Fax 02-269 85 03 • Gsm 0484-101 484 E-mail info#bwbouchout.be • Website www.bwbouchout.be Werkdagen: 8u - 16u30, vrijdag tot 14u45.
Personen met een fysieke en/of verstandelijke handicap. Ook psychiatrische patiënten en mensen met een meervoudige handicap.
Capaciteit: 180 tewerkstellingsplaatsen.
A problem: The portable phone number is written in another format as in the database. The database would say: 0484 10 14 84 the book says: 0484-101 484
The opening times are formulated completely different, but some of it is similar.
Are there tools which would make life easier? Tools where you would be able to find similar data something like: similar data finder for excel but then cross platform and with more possibilities? I believe most data exchange programs work very "one-way same for every entry". Is there a program which is more flexible?
For clarity: I need to compare the data, not to generate the data out of the database.
It could mean saving a lot of time, money and eyestrain. Thanks,
Erik Willekens
Erik,
The specific problem of comparing two telephone number which are formatted differently is relatively easy to overcome by stripping all non-numeric characters.
However I don't think that's really what you are trying to achieve. I believe you're attempting to compare whether the booklet data is different to the database data but disregard certain formatting.
Realistically this isn't possible without having some very well defined rules on the formatting. For instance formatting on the organisation name is probably very significant whereas telephone number formatting is not.
Instead you should be tracking changes within the database and then manually check the booklet.
One possible solution is to store the booklet details for each record in your database alongside the correctly formatted ones. This allows you to perform a manual conversion once for the entire booklet and then each subsequent year lets you just compare the new booklet values to the old booklet values stored in the DB.
An example might make this clearer. Imagine you had this very simple record:
Org Name Booklet Org Name GSM Booklet GSM
-------- ---------------- --- -----------
BESCHUTTE BESCHUTTE WERKP 0484 10 14 84 0484-101 484
When you get next year's booklet, then as long as the GSM number in the new booklet still says 0484-101 484 you won't have to worry about converting it to your database format and then checking to see if it has changed.
This would not be a good approach if a large proportion of details in the booklet changed each year

Supply Demand Modeling

I thought I would ask the SO community on helping me with a project that I am currently working on. I need to model the price for a widget in a market situation. The price for the widget should be a result from the current supply and demand. Users will be able to buy and sell the widget at the fixed price. As users buy the widget the demand will go up along with the price. Conversely as users sell the widget the supply will go up and the price will go down. The quantity and current price of the widget will be stored in a database along with the total number of buys and sells for the widget.
Protrade.com has an excellent example of buying and trading widgets (players and teams), I would want to model my system in a similar fashion.
Is there any good programming libraries that will accurately model a market based on supply and demand?
Unfortunately I do not know of any libraries, but perhaps you can tap into Excel's statistics functions.
My opinion follows.
This is why economics is so boring, everything is supply/demand.
Something along the lines of the following should work as a start:
ListPrice = (Cost + Profit) * (demand/supply * economic-factor)
where economic-factor is some determined constant.
If you have some historical data, eg daily supply/demand ratio's you could factor it in, perhaps using some time-based scale.

Resources