Re: problem with netCDF4 OpenDAP

2015-08-14 Thread Tom P

On 08/13/2015 05:55 PM, Jason Swails wrote:



On Thu, Aug 13, 2015 at 6:32 AM, Tom P mailto:werot...@freent.dd>> wrote:

I'm having a problem trying to access OpenDAP files using netCDF4.
The netCDF4 is installed from the Anaconda package. According to
their changelog, openDAP is supposed to be supported.

netCDF4.__version__
Out[7]:
'1.1.8'

Here's some code:

url =
'http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc'
nc = netCDF4.Dataset(url)

I get the error -
netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.__init__
(netCDF4/_netCDF4.c:9551)()

RuntimeError: NetCDF: file not found


However if I download the same file, it works -
url = '/home/tom/Downloads/ersst.201507.nc '
nc = netCDF4.Dataset(url)
print nc
  . . . .

Is it something I'm doing wrong?


​Yes.  URLs are not files and cannot be opened like normal files.
  netCDF4 *requires* a local file as far as I can tell.

All the best,
Jason

--
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral Researcher


Thanks for the reply but that is not what the documentation says.

http://unidata.github.io/netcdf4-python/#section8
"Remote OPeNDAP-hosted datasets can be accessed for reading over http if 
a URL is provided to the netCDF4.Dataset constructor instead of a 
filename. However, this requires that the netCDF library be built with 
OPenDAP support, via the --enable-dap configure option (added in version 
4.0.1)."


and for the Anaconda package -
http://docs.continuum.io/anaconda/changelog
"2013-05-08: 1.5.0:
Highlights:
  updates to all important packages: python, numpy, scipy, ipython, 
matplotlib, pandas, cython

  added netCDF4 (with OpenDAP support) on Linux and MacOSX"

--
https://mail.python.org/mailman/listinfo/python-list


Re: python command not working

2015-08-14 Thread sam . heyman
On Wednesday, April 22, 2009 at 8:36:21 AM UTC+1, David Cournapeau wrote:
> On Wed, Apr 22, 2009 at 4:20 PM, 83nini <83n...@gmail.com> wrote:
> > Hi guys,
> >
> > I'm new to python, i downloaded version 2.5, opened windows (vista)
> > command line and wrote "python", this should take me to the python
> > command line, but it did not! i'm getting : python is not an internal
> > command, external command, program, or command file.
> 
> The installer does not add the path of python into your %PATH%
> variable, You have to do it manually or call the full command path
> (C:\Python25\python.exe or something)
> 
> David


You can do it easily by adding the Python path (in my case C:\Python27) to your 
system PATH.

Simply go to Control Panel > System > Advanced system settings, select 
'Advanced' tab, click 'Environment Variables'.

There you need to add the path to Python (C:\Python27) to the Path BOTH:
- User variables
and
- System variables
For each one click 'Edit' and paste the path (C:\Python27) at the end of the 
line with a ';' to separate it

Restart your shell window and it should work!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Back off topic] - Hooking Mechanism when Entering and Leaving a Try Block

2015-08-14 Thread Sven R . Kunze
Am 14-Aug-2015 03:00:05 +0200 schrieb torr...@gmail.com:

> But I digress. We get sidetracked rather easily around here.

You don't say. ;)

-
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problem with netCDF4 OpenDAP

2015-08-14 Thread Jason Swails

> On Aug 14, 2015, at 3:18 AM, Tom P  wrote:
> 
> Thanks for the reply but that is not what the documentation says.
> 
> http://unidata.github.io/netcdf4-python/#section8
> "Remote OPeNDAP-hosted datasets can be accessed for reading over http if a 
> URL is provided to the netCDF4.Dataset constructor instead of a filename. 
> However, this requires that the netCDF library be built with OPenDAP support, 
> via the --enable-dap configure option (added in version 4.0.1).”

​Huh, so it does.  Your error message says "file not found", though, which 
suggested to me that it's trying to interpret the NetCDF file as a local file 
instead of a URL.  Indeed, when I run that example, the traceback is more 
complete (the traceback you printed had omitted some information):

>>> netCDF4.Dataset('http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc')
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or 
SCAN_ERROR
context: 404 Not FoundNot 
FoundThe requested URL 
/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc.dds was not found on this 
server.
Traceback (most recent call last):
  File "", line 1, in 
  File "netCDF4/_netCDF4.pyx", line 1547, in netCDF4._netCDF4.Dataset.__init__ 
(netCDF4/_netCDF4.c:9551)
RuntimeError: NetCDF: file not found

So it’s clear that netCDF4 is at least *trying* to go online to look for the 
file, but it simply can’t find it.  Since the docs say it’s linking to libcurl, 
I tried using curl to download the file (curl -# 
http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc > 
test.nc) and it worked fine.  What’s more, it *seems* like the file 
(/pub/.../ersst.201507.nc.dds) was decorated with the ‘.dds’ suffix for some 
reason (not sure if the server redirected the request there or not).  But this 
looks like a netCDF4 issue.  Perhaps you can go to their project page on Github 
and file an issue there -- they will be more likely to have your answer than 
people here.

HTH,
Jason

> 
> and for the Anaconda package -
> http://docs.continuum.io/anaconda/changelog
> "2013-05-08: 1.5.0:
> Highlights:
>  updates to all important packages: python, numpy, scipy, ipython, 
> matplotlib, pandas, cython
>  added netCDF4 (with OpenDAP support) on Linux and MacOSX"
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

--
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral Researcher

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problem with netCDF4 OpenDAP

2015-08-14 Thread Tom P

On 08/14/2015 03:15 PM, Jason Swails wrote:



On Aug 14, 2015, at 3:18 AM, Tom P  wrote:

Thanks for the reply but that is not what the documentation says.

http://unidata.github.io/netcdf4-python/#section8
"Remote OPeNDAP-hosted datasets can be accessed for reading over http if a URL 
is provided to the netCDF4.Dataset constructor instead of a filename. However, this 
requires that the netCDF library be built with OPenDAP support, via the --enable-dap 
configure option (added in version 4.0.1).”


​Huh, so it does.  Your error message says "file not found", though, which 
suggested to me that it's trying to interpret the NetCDF file as a local file instead of 
a URL.  Indeed, when I run that example, the traceback is more complete (the traceback 
you printed had omitted some information):


netCDF4.Dataset('http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc')

syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or 
SCAN_ERROR
context: 404 Not 
FoundNot FoundThe requested URL /pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc.dds was not found 
on this server.
Traceback (most recent call last):
   File "", line 1, in 
   File "netCDF4/_netCDF4.pyx", line 1547, in netCDF4._netCDF4.Dataset.__init__ 
(netCDF4/_netCDF4.c:9551)
RuntimeError: NetCDF: file not found

So it’s clear that netCDF4 is at least *trying* to go online to look for the file, 
but it simply can’t find it.  Since the docs say it’s linking to libcurl, I tried 
using curl to download the file (curl -# 
http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc > 
test.nc) and it worked fine.  What’s more, it *seems* like the file 
(/pub/.../ersst.201507.nc.dds) was decorated with the ‘.dds’ suffix for some 
reason (not sure if the server redirected the request there or not).  But this 
looks like a netCDF4 issue.  Perhaps you can go to their project page on Github 
and file an issue there -- they will be more likely to have your answer than 
people here.

HTH,
Jason


Hi,
  yes the file does appear to be there, I can download it and I can 
open and read the URL using urllib. Since there are a whole bunch of 
files in the directory, I really need MFDataset, but according to the 
documentation that doesn't work with URLs. Maybe the solution really is 
to D/L them all into a temporary folder and use MFDataset.






and for the Anaconda package -
http://docs.continuum.io/anaconda/changelog
"2013-05-08: 1.5.0:
Highlights:
  updates to all important packages: python, numpy, scipy, ipython, matplotlib, 
pandas, cython
  added netCDF4 (with OpenDAP support) on Linux and MacOSX"

--
https://mail.python.org/mailman/listinfo/python-list


--
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral Researcher



--
https://mail.python.org/mailman/listinfo/python-list


problem with netCDF4 OpenDAP

2015-08-14 Thread George Trojan

Subject:
problem with netCDF4 OpenDAP
From:
Tom P 
Date:
08/13/2015 10:32 AM

To:
python-list@python.org


I'm having a problem trying to access OpenDAP files using netCDF4.
The netCDF4 is installed from the Anaconda package. According to their 
changelog, openDAP is supposed to be supported.


netCDF4.__version__
Out[7]:
'1.1.8'

Here's some code:

url = 
'http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc'

nc = netCDF4.Dataset(url)

I get the error -
netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.__init__ 
(netCDF4/_netCDF4.c:9551)()


RuntimeError: NetCDF: file not found


However if I download the same file, it works -
url = '/home/tom/Downloads/ersst.201507.nc'
nc = netCDF4.Dataset(url)
print nc
 . . . .

Is it something I'm doing wrong?

Same thing here:

(devenv-3.4.1) dilbert@gtrojan> python
Python 3.4.1 (default, Jul  7 2014, 15:47:25)
[GCC 4.8.3 20140624 (Red Hat 4.8.3-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import netCDF4
>>> url = 
'http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc'

>>> nc = netCDF4.Dataset(url)
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET 
or SCAN_ERROR
context: 2.0//EN">404 Not FoundNot 
FoundThe requested URL 
/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc.dds was not found on this 
server.

Traceback (most recent call last):
  File "", line 1, in 
  File "netCDF4.pyx", line 1466, in netCDF4.Dataset.__init__ 
(netCDF4.c:19738)

RuntimeError: NetCDF: file not found
>>>

It looks like NCDC does not support OpeNDAP (note the .dds extension in 
the error message). It is not a Python/netCDF4 issue.


(devenv-3.4.1) dilbert@gtrojan> ncdump -h 
http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET 
or SCAN_ERROR
context: 2.0//EN">404 Not FoundNot 
FoundThe requested URL 
/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc.dds was not found on this 
server.
ncdump: 
http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc: 
NetCDF: file not found



George

-- 
https://mail.python.org/mailman/listinfo/python-list


New Intermediate Python Book

2015-08-14 Thread chuks155
Hi folks, 

I have just finished my first ebook titled Intermediate Python. It is targeted 
at users from other languages or that have just finished a python programming 
beginners tutorial. It is available at https://leanpub.com/intermediatepython. 
Content includes writings on python data model, object oriented programming, 
function and functional programming, sequence and generators, meta-programming, 
and modules and packages. 

If you would like to provide a review then I am willing to provide a copy for 
such. Just get in touch.
-- 
https://mail.python.org/mailman/listinfo/python-list


Fixing tkinter on 3.5.0rc1 for some Windows machines.

2015-08-14 Thread Terry Reedy
Symptom: Using 3.5.0rc1 on Windows machines without VS2015 installed, 
import tkinter or use something that does so (Idle, Turtle, turtledemo, 
...) and get message "Your Python may not be configured for Tk."


Fix: In install directory, find /DLLs. In that find /MicrosoftVC140.CRT 
with one file vcruntime140.dll.  Move this file up into /DLLs


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Help with Flask (database stage of the Flask Mega Tutorial by Miguel Grinberg)

2015-08-14 Thread Jacob MacRitchie
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iv-database

I've just finished making db_create.py (you can ctrl+f to it) and am getting...

from migrate.versioning import api
ImportError: No module named 'migrate'

...I diffed everything at this stage of the tutorial so I know I have no typos, 
I double checked my venv to make sure I have sqlalchemy-migrate installed. I 
did notice in the comments (page 2 of the comments I think) that the newer 
version of SQLAlchemy isn't compatible with sqlalchemy-migrate, so is that 
what's causing this problem? I didn't find anyone else having quite the same 
problem.

I tried downgrading sqlalchemy to 0.7.9 (necessary for other parts of the 
tutorial, but didn't solve this problem), tried running from the command line 
(venv activated) instead of running it with the venv selected as project 
interpreter in pycharm, but get...

from config import SQLALCHEMY_DATABASE_URI
ImportError: no module named 'config'

...instead. I've tried moving db_create.py from the app folder for the heck of 
it, but just get a long traceback.

I'm not sure what else to try, any help is appreciated!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Vaga Java (Belgica, com tudo pago)

2015-08-14 Thread David H. Lipman

From: "leo kirotawa" 

Wondering why a position for Java/JS was sent to this list...just 
wondering...




Because spammers make no sense.

--
Dave
Multi-AV Scanning Tool - http://multi-av.thespykiller.co.uk
http://www.pctipp.ch/downloads/dl/35905.asp 


--
https://mail.python.org/mailman/listinfo/python-list


Re: How to model government organization hierarchies so that the list can expand and compress

2015-08-14 Thread Friedrich Rentsch



On 08/13/2015 09:10 PM, Alex Glaros wrote:

It's like the desktop folder/directory model where you can create unlimited 
folders and put folders within other folders. Instead of folders, I want to use 
government organizations.

Example: Let user create agency names: Air Force, Marines, Navy, Army. Then let them 
create an umbrella collection called "Pentagon", and let users drag Air Force, 
Marines, Navy, etc. into the umbrella collection.

User may wish to add smaller sub-sets of Army, such as "Army Jeep Repair 
Services"

User may also want to add a new collection "Office of the President" and put 
OMB and Pentagon under that as equals.

What would the data model look like for this?  If I have a field: 
next_higher_level_parent that lets children records keep track of parent 
record, it's hard for me to imagine anything but an inefficient bubble sort to 
produce a hierarchical organizational list. Am using Postgres, not graph 
database.

I'm hoping someone else has worked on this problem, probably not with 
government agency names, but perhaps the same principle with other objects.

Thanks!

Alex Glaros


After struggling for years with a tree-like estate management system 
(onwer at the top, next level: real estate, banks, art collection, etc., 
third level: real estate units, bank accounts, etc. fourth level: 
investment positions, currency accounts, etc)--it recently occurred to 
me that I had such a system all along: the file system. The last folder 
at the bottom end of each branch names its contents (AAPL or USD or 
Lamborghini, etc) the contents is a csv file recording an in and out, 
revenue, expense history (date, quantity, paid or received, memo, . . 
.). Any documentation on the respective value item may also be stored in 
the same folder, easy to find without requiring cross referencing.


Managing the data is not a awkward as one might fear. A bash wizard 
could probably do it quite efficiently with bash scripts. Bash dummies, 
like me, are more comfortable with python. Moving, say, a portfolio from 
one bank to another is a matter of "mv i/banks/abc/account-123 
i/banks/xyz" (system call). With the tabular data base system (MySQL) I 
have, simple operations like this one are quite awkward.


Well, you might laugh. Or others might. If your task is a commercial 
order, then this approach will hardly do. Anyway, I thought I'd toss it 
up. If it won't help it won't hurt.


Frederic







--
https://mail.python.org/mailman/listinfo/python-list


Re: How to model government organization hierarchies so that the list can expand and compress

2015-08-14 Thread Alex Glaros
Frank, thanks for describing the terminology of what I'm trying to do.

1. Do the recursive join Postgres examples you linked to, use a data structure 
where the child has the adjoining parent-ID? Examples look great.

2. Not 100% sure that hierarchical is the perfect solution but will go with 
that now. Of course some agencies will be at equal levels; will ignore for now.

3. Could not find Laura's response. Was it deleted?

4. Solution will expressed in the DB, not Python.

Much appreciated!

Alex

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to model government organization hierarchies so that the list can expand and compress

2015-08-14 Thread Rustom Mody
On Saturday, August 15, 2015 at 5:12:13 AM UTC+5:30, Alex Glaros wrote:
> 3. Could not find Laura's response. Was it deleted?

I dont see it either. I expect its in some other thread
Laura's mail client is doing funny things to threading... 
Something Ive been noticing for a few days
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problem with netCDF4 OpenDAP

2015-08-14 Thread Michael Ströder
Tom P wrote:
>   yes the file does appear to be there, I can download it and I can open and
> read the URL using urllib. Since there are a whole bunch of files in the
> directory, I really need MFDataset, but according to the documentation that
> doesn't work with URLs. Maybe the solution really is to D/L them all into a
> temporary folder and use MFDataset.

Not sure about the size and other aspects of your deployment. But the safest
way to backup an OpenLDAP database is to export it to a single LDIF file
because this can be done while slapd is running and it's guaranteed that the
LDIF contains only data of finished transactions.

Ciao, Michael.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to model government organization hierarchies so that the list can expand and compress

2015-08-14 Thread Laura Creighton
In a message of Fri, 14 Aug 2015 16:42:00 -0700, Alex Glaros writes:
>Frank, thanks for describing the terminology of what I'm trying to do.
>
>1. Do the recursive join Postgres examples you linked to, use a data structure 
>where the child has the adjoining parent-ID? Examples look great.
>
>2. Not 100% sure that hierarchical is the perfect solution but will go with 
>that now. Of course some agencies will be at equal levels; will ignore for now.
>
>3. Could not find Laura's response. Was it deleted?
>
>4. Solution will expressed in the DB, not Python.
>
>Much appreciated!
>
>Alex

What I said was, that real agencies are almost never perfectly
heirarchical.  That's an oversimplification.  In the real world
Organisation A (say Army) and Organisation B (say Navy) decide they
have common interests and make a Joint Department.  If you run that
department you report to superiors in _both_ organisation A and
organisation B, get orders from both places and so on and so forth.
You must decide now what you want to do when you run into such
departments, because that will greatly influence your design.

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to model government organization hierarchies so that the list can expand and compress

2015-08-14 Thread Frank Millman
"Alex Glaros"  wrote in message 
news:ae4e203d-c664-4388-af0b-41c41d5ec...@googlegroups.com...



Frank, thanks for describing the terminology of what I'm trying to do.

1. Do the recursive join Postgres examples you linked to, use a data 
structure where the child has the adjoining parent-ID? Examples look 
great.


I think that their example is very simple - it seems that each level 
contains one link to the level below, and the level below has no link to the 
level above (or at least they did not make use of it).


The following (untested) example assumes that each row can have multiple 
children, and each row has a link to its parent called parent_id.


   WITH RECURSIVE included_parts(part, quantity) AS (
   SELECT  part, quantity FROM parts WHERE part = 'our_product'
 UNION ALL
   SELECT p.part, p.quantity
   FROM included_parts pr, parts p
   WHERE p.parent_id = pr.part
 )
   SELECT part, SUM(quantity) as total_quantity
   FROM included_parts
   GROUP BY part

You will find many variations in various on-line tutorials. For example, you 
can traverse *up* the tree by changing the WHERE clause to WHERE p.part = 
pr.parent_id




2. Not 100% sure that hierarchical is the perfect solution but will go 
with that now. Of course some agencies will be at equal levels; will 
ignore for now.


3. Could not find Laura's response. Was it deleted?



Laura responded to this in another post, but in case you cannot see that one 
either, I reproduce it here -


"""
What I said was, that real agencies are almost never perfectly
heirarchical.  That's an oversimplification.  In the real world
Organisation A (say Army) and Organisation B (say Navy) decide they
have common interests and make a Joint Department.  If you run that
department you report to superiors in _both_ organisation A and
organisation B, get orders from both places and so on and so forth.
You must decide now what you want to do when you run into such
departments, because that will greatly influence your design.
"""


4. Solution will expressed in the DB, not Python.



Much appreciated!


Glad I could help.

Frank


--
https://mail.python.org/mailman/listinfo/python-list


Re: AttributeError

2015-08-14 Thread Ben Finney
Ltc Hotspot  writes:

> So calling people stupid and ignorant on the internet makes you sexual
> arousal and to masturbate with yourself

With that, you have worn out your welcome here. Please don't post here
again until you can refrain from puerile demeaning insults.

-- 
 \ “Alternative explanations are always welcome in science, if |
  `\   they are better and explain more. Alternative explanations that |
_o__) explain nothing are not welcome.” —Victor J. Stenger, 2001-11-05 |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Global command doesn't seem to work...

2015-08-14 Thread Dwight GoldWinde
Inside of Functions.py I define the function:

def subwords ():
global subwordsDL
subwordsDL = {'enjoy':['like', 'appreciate', 'love', 'savor'],
'hurt':['damage', 'suffering']}
print (subwordsDL)
Return

In my test code module, the code is:

global subwordsDL
from Functions import subwords
subwords ()
print (subwordsDL)
print (subwordsDL['enjoy'][2])

I get an error on the 4th line of this module (BTW, I tried this module with
and without the first line, reaffirming subwordsDL as global, and the
results are the same):

{'hurt': ['damage', 'suffering'], 'enjoy': ['like', 'appreciate', 'love',
'savor']}
Traceback (most recent call last):
  File "test short.py", line 4, in 
print (subwordsDL)
NameError: name 'subwordsDL' is not defined


LOLŠworked on this for over an hourŠ


Please help.


BIG SMILE...


Always, Dwight









-- 
https://mail.python.org/mailman/listinfo/python-list


Python 2.7: _PyLong_NumBits() Segfault

2015-08-14 Thread Adam Meily
I am working on a CPython library that serializes Python objects to disk in
a custom format. I'm using _PyLong_NumBits() to determine whether
PyLong_AsLong(), PyLong_AsUnsignedLong(), PyLong_AsLongLong(), or
PyLong_AsUnsignedLongLong() should be used.

In Python 3.x, I'm able to determine how many bits are required to write an
int to disk without issue. However, in Python 2.7, _PyLong_NumBits()
segfaults when the type is a PyInt that has the value of 0x
(maximum unsigned 32-bit value). Additionally, _PyLong_NumBits() is not
accurate when the number is negative. My guess is that I can't use
_PyLong_NumBits() on a PyInt object. So, what is the correct way to
determine the number of bits required to represent a PyInt object in Python
2.7?

I'm using Python 2.7.6, x86-64 on Ubuntu.
-- 
https://mail.python.org/mailman/listinfo/python-list


memory control in Python

2015-08-14 Thread Ping Liu
Dear All,

I am working on an optimization problem, where we are trying to minimize
some indicators like energy usage, energy cost, CO2 emission. In this
problem, we have a bunch of energy conversion technologies for electricity
and thermal purpose, such as heat pump, boiler, chiller, etc.. We are
trying to model it with a one year time period. the current time step is
one hour.

We have preselected the  candidate technologies to exclude those we don't
want to study so that the problem size could be reduced with a limited
candidate technologies. In the current case study, we only analyze the
electric chiller and heat pump to supply the cooling load, while power grid
will supply the electricity for all electric loads. There are binary
variables regarding installation decisions of technologies and continuous
variables related to installation capacity and hourly operational
decisions.

For small cases, Python works well. But if we consider longer time period.
then it would fail due to the memory usage issues. We have tested several
case studies to check the memory use for different time period, including
1) 2 hours in one day, 2) 24 hours in one day, 3) 20 days with 24 hours
each day, as well as 4) 30 days with 24 hours each day. The first 3 cases
are feasible while the last case gives out the memory error.

When we are testing the forth case, the memory error comes out while
creating the inequality constraints. The problem size is 1) Aeq: 12 * 26,
Aineq: 30 * 26; 2) Aeq: 144*268, Aineq:316*268; 3) Aeq: 2880*5284, Aineq:
6244*5284; 4) Aeq: 4320 * 7924, Aineq is unknown due to the memory error.

The solver is CPLEX (academic). It turns out that the solver is taking a
lot of memory as you can see in the memory test report. for the first three
cases, different memory usage is observed, and it grows up dramatically
with the increase of the time period. 1) solver memory usage: 25.6 MB, 2)
19.5 MB; 3) solver memory usage: 830.0742 MB.

Based on my observations, I have some of the following questions regarding
1) In order to create the optimization problem (Aeq, Aineq), how can we
reduce the memory usage in python programming?  2) how can I reduce the
memory usage of different solvers in Python? Why would the memory decrease
for the CPLEX solver within the 24-hours-in-one-day case compared with the
case 1?

Thanks in advance,
Ping


solver memory comparison.xlsx
Description: MS-Excel 2007 spreadsheet
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Global command doesn't seem to work...

2015-08-14 Thread Chris Angelico
On Thu, Aug 13, 2015 at 9:06 PM, Dwight GoldWinde  wrote:
> global subwordsDL
> from Functions import subwords
> subwords ()
> print (subwordsDL)
> print (subwordsDL['enjoy'][2])

In Python, "global" means module-level. The easiest way to do this
would be to import the Functions module directly (rather than using a
from-import), and then you can use Function.subwords and
Functions.subwordsDL.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list